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,P,Q,R,S,T,U,V,W,X,Y,Z
Is there something in Javascript that will allow this to be done just as easy? if not, is there Node module that allows for something similar?
Javascript doesn’t have that functionality natively. Below you find some examples of how it could be solved:
Normal function, any characters from the base plane (no checking for surrogate pairs)
The same as above, but as a function added to the array prototype, and therefore available to all arrays:
A range from preselected characters. Is faster than the functions above, and let you use
alphanum_range('A','z')to mean A-Z and a-z:Or any character from the ascii range. By using a cached array, it is faster than the functions that build the array every time.