12/15 .length-based end question


Why do we want the for loop to end when the variable [i] is less than the number of strings in the array? Wouldn't that mean we miss the last item in the array?

I've tried <= in the loop and it returns an extra, "undefined" name. Shouldn't it cease to run if [i] equals more than the number of items in the array?


That's got to do with the way you count in arrays. Meaning that you don't start counting at 1 but at zero so if you have an array of 4 entries then the indices are 0,1,2,3 as you can see because you startet counting at 0 the biggest index is exactly 1 smaller than the number of entries itself so we use < .length to mark the end.