1.8 KiB
		
	
	
	
	
	
	
	
			
		
		
	
	
			1.8 KiB
		
	
	
	
	
	
	
	
id, title, challengeType, forumTopicId, dashedName
| id | title | challengeType | forumTopicId | dashedName | 
|---|---|---|---|---|
| 5a23c84252665b21eecc7e7a | Generate lower case ASCII alphabet | 5 | 302274 | generate-lower-case-ascii-alphabet | 
--description--
Write a function to generate an array of lower case ASCII characters for a given range. For example, given the range ['a', 'd'], the function should return ['a', 'b', 'c', 'd'].
--hints--
lascii should be a function.
assert(typeof lascii == 'function');
lascii("a","d") should return an array.
assert(Array.isArray(lascii('a', 'd')));
lascii('a','d') should return [ 'a', 'b', 'c', 'd' ].
assert.deepEqual(lascii('a', 'd'), results[0]);
lascii('c','i') should return [ 'c', 'd', 'e', 'f', 'g', 'h', 'i' ].
assert.deepEqual(lascii('c', 'i'), results[1]);
lascii('m','q') should return [ 'm', 'n', 'o', 'p', 'q' ].
assert.deepEqual(lascii('m', 'q'), results[2]);
lascii('k','n') should return [ 'k', 'l', 'm', 'n' ].
assert.deepEqual(lascii('k', 'n'), results[3]);
lascii('t','z') should return [ 't', 'u', 'v', 'w', 'x', 'y', 'z' ].
assert.deepEqual(lascii('t', 'z'), results[4]);
--seed--
--after-user-code--
let results=[
  [ 'a', 'b', 'c', 'd' ],
  [ 'c', 'd', 'e', 'f', 'g', 'h', 'i' ],
  [ 'm', 'n', 'o', 'p', 'q' ],
  [ 'k', 'l', 'm', 'n' ],
  [ 't', 'u', 'v', 'w', 'x', 'y', 'z' ]
]
--seed-contents--
function lascii(cFrom, cTo) {
}
--solutions--
function lascii(cFrom, cTo) {
  function cRange(cFrom, cTo) {
    var iStart = cFrom.charCodeAt(0);
    return Array.apply(
      null, Array(cTo.charCodeAt(0) - iStart + 1)
    ).map(function (_, i) {
      return String.fromCharCode(iStart + i);
    });
  }
  return cRange(cFrom, cTo);
}