How to generate an array of the alphabet?
javascript
Solution
You can easily make a function to do this for you if you'll need it a lot
function genCharArray(charA, charZ) {
var a = [], i = charA.charCodeAt(0), j = charZ.charCodeAt(0);
for (; i <= j; ++i) {
a.push(String.fromCharCode(i));
}
return a;
}
console.log(genCharArray('a', 'z')); // ["a", ..., "z"]
Problem
In Ruby I can do `('a'..'z').to_a` to get `['a', 'b', 'c', 'd', ... 'z']`. Does JavaScript provide a similar construct?