I\'m using Underscore\'s template() method in BackboneJS views. I\'d like to show a list of alphabet letters in my view in order to sort a collection by letter.
As a
for (var i = 'a'.charCodeAt(0); i <= 'z'.charCodeAt(0); i++) {
console.log(String.fromCharCode(i));
}
for(var letter=65;letter<91;letter++)
{
var _char = String.fromCharCode(letter);
console.log(_char);
}
or use from 97 - 123 ascii code for lowercase letters
Here's an improved* version of @Medo Medo's pure JS code:
var letters=[], letter_first = 'a', letter_last = 'z' // you can also use A and Z
for (var letter=letter_first.charCodeAt(0);letter<=letter_last.charCodeAt(0);letter++)
letters.push(String.fromCharCode(letter))
document.write(letters.join(''))