-1

Quick question. I am trying to give out numbers with a for loop in JavaScript. Unfortunately this is not working, if I would code in java then the solution would be replace var with char and cosole.log with println and got it, but here… do you have a solution for that ?

for ( var i = 'a'; i < 'z'; i++) {
    console.log(i);
}
Mchoeti
  • 536
  • 1
  • 8
  • 24

1 Answers1

-1

for (var i = 'a'; i !== nextChar('z'); i = nextChar(i)) {
    console.log(i);
}
        
function nextChar(c) {
    return String.fromCharCode(c.charCodeAt(0) + 1);
}
online Thomas
  • 8,864
  • 6
  • 44
  • 85