Get a range of characters (Functional ES6 JavaScript)

It can be useful to grab every character in order from the alphabet when you are coding sometimes. For example, if you wanted to display a ordinal list by letters, like a mulitple choice test. Some languages give this to you out of the box (Perl, Ruby) but JavaScript is not one of them.

Here is a short function I wrote that will return a list of the characters given a starting and end point. I use the range function I detailed in an early entry.

const rangeAlpha = (start, stop)  => {
    start = start.charCodeAt(0);
    stop = stop.charCodeAt(0);
    return range(start, stop + 1).map(code => String.fromCharCode(code));
};

Here's the JSFiddle to see it in action.