Answers for "loop through string js"

8

javascript loop through string

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

loop through string js

const str = "Hello Grepper!";
const chars = [...str];
chars.forEach((c, i) => console.log(c, i));
Posted by: Guest on October-10-2021
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 "TypeScript"

Browse Popular Code Answers by Language