I read some code where someone did this in Ruby:
puts (\'A\'..\'Z\').to_a.join(\',\')
output:
A,B,C,D,E,F,G,H,I,J,K,L,M,N,O
Maybe this function will help you.
function range ( low, high, step ) { // Create an array containing a range of elements
//
// + original by: _argos
var matrix = [];
var inival, endval, plus;
var walker = step || 1;
var chars = false;
if ( !isNaN ( low ) && !isNaN ( high ) ) {
inival = low;
endval = high;
} else if ( isNaN ( low ) && isNaN ( high ) ) {
chars = true;
inival = low.charCodeAt ( 0 );
endval = high.charCodeAt ( 0 );
} else {
inival = ( isNaN ( low ) ? 0 : low );
endval = ( isNaN ( high ) ? 0 : high );
}
plus = ( ( inival > endval ) ? false : true );
if ( plus ) {
while ( inival <= endval ) {
matrix.push ( ( ( chars ) ? String.fromCharCode ( inival ) : inival ) );
inival += walker;
}
} else {
while ( inival >= endval ) {
matrix.push ( ( ( chars ) ? String.fromCharCode ( inival ) : inival ) );
inival -= walker;
}
}
return matrix;
}
console.log(range('A','Z'))
// ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"]
This is not mine, taken from: http://javascript.ru/php/range