![]() ![]() TL DR: Whatever is inside the for loop, run it 20 times beginning from 0 (starting value of i) to 19 (ending value of i) and increment i by 1. ![]() Point 3: Since you want to check for every element in the array, you increment i by 1. The length of the array is 20! Therefore, with this stop condition we make sure that i will never be greater than 19, which is the index of the last Object in the array. Therefore, you would always want i to be less than or equal to the last position of the array. Point 2: You want to run the loop for all the individuals in the array. To do that, you initialize a new variable i with the value 0. We need to run the if code block for every element in the array from index 0 to index 19 (length is 20). ![]() Length of the array can be accessed by array.length.You index an element with square brackets, for example: individuals will return the details for Aaron.The position of the first element is denoted by 0. ![]()
0 Comments
Leave a Reply. |