Answers for "put a sample array in for loop"

1

create a loop that runs through each item in an array

Create a loop that runs through each item in the "fruits" array.

var fruits = ['Apple', 'Banana', 'Orange']

for(x of fruits){
	console.log(x);
}
Posted by: Guest on June-10-2021
0

Iterate Through an Array with a 'for' loop

var total = 0;
for (var i = 0; i < myArr.length; i++) {
  total += myArr[i];
}
Posted by: Guest on December-17-2021

Browse Popular Code Answers by Language