Answers for "looping a string in 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
9

javascript loop through string

for (var i = 0; i < str.length; i++) {
  console.log(str.charAt(i));
}
Posted by: Guest on June-01-2020
0

loop over string js

// for ... of ...
for (let char of "Hello") {
  console.log(char);
}

// console result:
H
e
l
l
o
Posted by: Guest on July-27-2021

Code answers related to "looping a string in javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language