Answers for "loop for loop javascript"

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
1

javascript loop

//There are many loops in javascript that get the job done
let colors = ["red","blue","green"];

//More detail about loop => shorturl.at/avIRW
for(let i in colors){
  console.log(colors[i])
}
//More detail about loop => shorturl.at/hBUW2
colors.forEach(color => {
  console.log(color)
})
//More detail about loop => shorturl.at/pLOV6
colors.map(color => {
  console.log(color)
})
//More detail about loop => shorturl.at/hlstV
for(let i = 0; i < colors.length; i++){
  console.log(colors[i])
}
//More detail about loop => shorturl.at/iKS38
let i = 0;
while ( i < colors.length ){
  console.log(colors[i])
  i++
}
Posted by: Guest on September-01-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language