for loop

PHOTO EMBED

Sat Jan 15 2022 19:01:04 GMT+0000 (UTC)

Saved by @alba #python #javascript #array #list #forloop #iteration

JavaScript

for (let i=0; i < arrayName.length; i++){
  console.log(arrayName[i])
}

i.e.):

movies = ['legally blonde', 'Ms. & Ms. Smith', 'The Incredibles'];

for (let i=0; i < movies.length; i++){
  console.log(movies[i])
}

Python

for singular_array_name in array_name_pluralized:
	print(singular_array_name)

i.e.):

movies = ['legally blonde', 'Ms. & Ms. Smith', 'The Incredibles']

for movie in movies:
	print(movie)
content_copyCOPY

JS explained i represents the index and you are setting it to 0 because arrays and lists are index based and they start at zero then you are saying as long that index is less than the length of the array then continue adding i++