Pages

🪛DM

 /**

*
 * @param {String} start The first letter
 * @param {String} end The last letter
 * @param {Number} step The step between letter
 * @returns {Array} Return a new array of charCode between start and end
 */
function codeRange(start, end, step = 1) {
  return new Array(Math.ceil((end.charCodeAt(0) - start.charCodeAt(0)) / step))
    .fill(start.charCodeAt(0))
    .map((x, i) => i * step + start.charCodeAt(0));
}

/**
 * A specialized version of `_.map` for arrays without support for callback
 * shorthands and `this` binding.
 *
 * @private
 * @param {Array} array The array to iterate over.
 * @param {Function} iteratee The function invoked per iteration.
 * @returns {Array} Returns the new mapped array.
 */
function arrayMap(array, iteratee) {
  var index = -1,
    length = array.length,
    result = Array(length);

  while (++index < length) {
    result[index] = iteratee(array[index], index, array);
  }
  return result;
}

const codes = codeRange("A", "H", 2);
// find the iteratee code to map string from charCode
const Letters = arrayMap(codes, --?--);

console.table(Letters);
┌─────────┬────────┐ │ (index) │ Values │ ├─────────┼────────┤ │ 0 │ 'A' │ │ 1 │ 'C' │ │ 2 │ 'E' │ │ 3 │ 'G' │ └─────────┴────────┘