Answers for "how to use for statement js"

220

javascript for loop

var colors=["red","blue","green"];
for (let i = 0; i < colors.length; i++) { 
  console.log(colors[i]);
}
Posted by: Guest on June-17-2019
3

javascript loop

JavaScript supports different kinds of loops:

for - loops through a block of code a number of times
for/in - loops through the properties of an object
for/of - loops through the values of an iterable object
while - loops through a block of code while a specified condition is true
do/while - also loops through a block of code while a specified condition is true

for (let i = 0; i < cars.length; i++) {
  text += cars[i] + "<br>";
}
Posted by: Guest on August-06-2021

Code answers related to "how to use for statement js"

Code answers related to "Javascript"

Browse Popular Code Answers by Language