@writetome51/get-alphabetical-range

Returns array of alphabetical characters, starting and ending with characters of your choice

Usage no npm install needed!

<script type="module">
  import writetome51GetAlphabeticalRange from 'https://cdn.skypack.dev/@writetome51/get-alphabetical-range';
</script>

README

getAlphabeticalRange(
      startingLetter,
      endingLetter,
      increment? = 1
): string[]

Returns array of English letters in ascending or descending order, depending on what
startingLetter and endingLetter are, and which comes first in the alphabet.
If startingLetter is uppercase, the returned letters will all be uppercase.

Examples

getAlphabeticalRange('a', 'f');
    // --> ["a", "b", "c", "d", "e", "f"]
    
getAlphabeticalRange('f', 'a');
    // --> ["f", "e", "d", "c", "b", "a"]
    
getAlphabeticalRange('a', 'o', 2);
    // --> [ 'a', 'c', 'e', 'g', 'i', 'k', 'm', 'o' ]
    
getAlphabeticalRange('A', 'o', 2);
    // --> [ 'A', 'C', 'E', 'G', 'I', 'K', 'M', 'O' ]
    
getAlphabeticalRange('z', 'M', 3);
    // --> [ 'z', 'w', 't', 'q', 'n' ]
    
getAlphabeticalRange('M', 'z', 3);
    // --> [ 'M', 'P', 'S', 'V', 'Y' ]

Installation

npm i @writetome51/get-alphabetical-range

Loading

// if using TypeScript:
import {getAlphabeticalRange} from '@writetome51/get-alphabetical-range';
// if using ES5 JavaScript:
var getAlphabeticalRange = 
    require('@writetome51/get-alphabetical-range').getAlphabeticalRange;

License

MIT