1// Sequence generator function (commonly referred to as "range", e.g. Clojure, PHP etc)
2const range = (start, stop, step) => Array.from({ length: (stop - start) / step + 1}, (_, i) => start + (i * step));
3
4// Generate numbers range 0..4
5range(0, 4, 1);
6// [0, 1, 2, 3, 4]
7
8// Generate numbers range 1..10 with step of 2
9range(1, 10, 2);
10// [1, 3, 5, 7, 9]
11
12// Generate the alphabet using Array.from making use of it being ordered as a sequence
13range('A'.charCodeAt(0), 'Z'.charCodeAt(0), 1).map(x => String.fromCharCode(x));
14// ["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"]
15