WEBVTT 00:06.260 --> 00:12.920 In this chapter you're going to learn new iteration features and concepts in iOS 6 as well as new data 00:12.920 --> 00:17.600 structures which will make your javascript experience a lot easier. 00:17.930 --> 00:23.740 So first let's start with a new loop in iOS 6 which is the four of you. 00:24.080 --> 00:27.250 So first let's go back to our traditional for loop 00:30.730 --> 00:34.080 and build a simple example where you just 00:37.620 --> 00:51.930 a simple loop going from 0 to to and printing ie to the console. 00:52.690 --> 00:56.530 So this is a simple loop right now. 00:59.330 --> 01:06.320 We know that we had features which could be used with the for loop like the brake feature. 01:06.320 --> 01:08.900 So for example you can decide 01:11.840 --> 01:15.650 to break it by says condition is fulfilled. 01:15.680 --> 01:17.090 So for example if I 01:20.100 --> 01:28.070 is equal to one you can decide to break and this will stop the loop so you can see all of this. 01:28.230 --> 01:37.980 This new loop starts prints zero and then once I's equal to one it breaks and the loop just ends all 01:37.980 --> 01:38.850 stops. 01:38.850 --> 01:40.310 All right. 01:40.490 --> 01:49.560 You must be also familiar with the for each method which is used with arrays. 01:49.640 --> 01:51.110 So let's create an array 01:57.670 --> 01:58.390 comics 02:02.590 --> 02:03.500 code for instance. 02:03.510 --> 02:09.290 This would the BMW and Ford 02:14.500 --> 02:25.260 and let's say this we can loop through the array using for each to which we can pass a function so you 02:25.260 --> 02:28.200 can use an arrow function or a traditional function. 02:28.230 --> 02:38.180 So let's go for an arrow function so let's pass to the function a couple of elements the elements right 02:38.620 --> 02:40.410 and the index. 02:40.520 --> 02:45.140 So if you pass only one value then it's going to refer to the value of the elements. 02:45.140 --> 02:51.980 If you pass the second parameter then it's going to add to the index of that element. 02:52.790 --> 02:58.360 So let's say that's our function is just going to look something to the console. 02:59.510 --> 03:05.210 So let's look something like let's use string. 03:05.210 --> 03:14.620 LEIGH SALES And what template template which liberals let's say lets the make can have MAKE NO. 03:14.950 --> 03:16.230 NO ONE 1. 03:16.240 --> 03:17.640 And so on. 03:18.010 --> 03:24.510 So that number is going to be the index plus one. 03:24.510 --> 03:24.960 All right. 03:24.990 --> 03:29.710 And then as I go on. 03:29.930 --> 03:38.270 And then after that we're gonna have the name of the make which is the element variable. 03:38.440 --> 03:39.650 All right. 03:39.690 --> 03:40.710 So let's try this 03:43.810 --> 03:48.030 and you can see that our loop is working as expected. 03:48.110 --> 03:48.280 Right. 03:48.280 --> 03:54.840 So now we can see that we've got a choice between using a simple for loop or for each. 03:54.840 --> 03:56.890 When it comes to arrays. 03:56.970 --> 04:06.800 Now let's move to yes six is four of loop so you would use the four off loop to loop over an array. 04:06.930 --> 04:12.670 So let's build an example using our comics array so the syntax is pretty simple. 04:12.690 --> 04:24.650 It's gonna be four and then inside parentheses you're going to specify the name of the variable which 04:24.650 --> 04:26.880 will refer to the elements of the array. 04:26.990 --> 04:29.750 So let's call it s x for example. 04:31.040 --> 04:36.580 So I'm using quantity here because X is not gonna change right. 04:36.590 --> 04:45.440 So usually when you use for you use const to declare the iterator all the variable referring to the 04:45.440 --> 04:55.970 elements in Siberia so or concert x of 0 Array let's say that we're just gonna bring X 04:58.880 --> 04:59.730 here we go. 04:59.770 --> 05:01.530 It works as expected. 05:01.890 --> 05:02.460 All right. 05:03.280 --> 05:06.710 We can also break out some points like we did there. 05:07.070 --> 05:09.530 So you can decide to break if 05:12.550 --> 05:25.470 the volume X is BMW for example and then you can see that you started the loop you printed Audi and 05:25.650 --> 05:32.130 once you got the B condition is fulfilled to break up you're gonna stop the loop right there that's 05:32.130 --> 05:34.050 why you see early Audi. 05:35.100 --> 05:43.050 All right in the next video you're going to learn a new E6 concept which is called the iterator.