For Loops: Vacation Spots 3/8

let vacationSpots = ['Scotland', 'Namibia', 'Australia'];

for (let vacationSpotIndex = 0; vacationSpotIndex < vacationSpots.length; vacationSpotIndex++) {
  console.log('I would love to visit ' + vacationSpots[vacationSpotIndex]);

So I’m not having much trouble understanding ‘for’ loops so far. My questions is around how vacationSpotIndex picks up the strings from vacationSpots. I can’t see how console.log(… + vacationSpots[vacationSpotsIndex]) allows the index to use the strings from vacationSpots…

Does entering ‘vacationSpots[vacationSpotIndex]’ into console.log tie the index to the array?


array[index] =>  element value

As we can see, the loop does not see the strings. They are accessed by their index.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.