Understand the functioin but not the notation that represents it. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Understand the functioin but not the notation that represents it.

Does the part with myArr.length;x++ mean that it counts up in the length of myArr without surpassing the number of int 3 because it starts countinf at 0?

8th Mar 2017, 3:39 AM
J. Shydigga
J. Shydigga - avatar
1 Answer
0
The length property will count the total number of elements in the array and set its value equal to length. So: var arr = Array {0,1,2,3,4,5,6,7,8,9} has 10 elements, in any loop such as i < myArr.Length it will increment i to 3, test the condition and because (i = 3) is not less than (myArr.length = 3) the condition will fail. However yes, because i started at 0, then 1 and 2, it still counted 3 elements in the array. Hope that helps.
8th Mar 2017, 3:45 AM
Elfren Authorlee
Elfren Authorlee - avatar