-2

I can't print each letter of my name

     let str = "Ashman"
       console.log(str[0])
     for ( let i = 0 ; str<str.length; i++) {
       console.log(str)
     }
Neeraj
  • 9

2 Answers2

0

You are almost correct.

console.log(str[i]) should work and str<str.length should be i<str.length

let str = "Ashman";
for (let i = 0; i < str.length; i++) {
  console.log(str[i])
}
kiranvj
  • 32,342
  • 7
  • 71
  • 76
0

To access each letter you need to insert your console.log(str[0]) inside for loop and change the [0] using your for loop variable.

let str= "Ashman";
for(let i = 0; i < str.length; i++){
  let x = str[i];
  console.log(x)
}