93 lines
3.2 KiB
Markdown
93 lines
3.2 KiB
Markdown
![]() |
---
|
||
|
title: Generate lower case ASCII alphabet
|
||
|
id: 5a23c84252665b21eecc7e7a
|
||
|
localeTitle: 5a23c84252665b21eecc7e7a
|
||
|
challengeType: 5
|
||
|
---
|
||
|
|
||
|
## Description
|
||
|
<section id='description'>
|
||
|
Escriba una función para generar una matriz de caracteres ASCII en minúsculas, para un rango determinado. Por ejemplo: para el rango 1 a 4, la función debe devolver <code>['a','b','c','d']</code> .
|
||
|
</section>
|
||
|
|
||
|
## Instructions
|
||
|
<section id='instructions'>
|
||
|
|
||
|
</section>
|
||
|
|
||
|
## Tests
|
||
|
<section id='tests'>
|
||
|
|
||
|
```yml
|
||
|
tests:
|
||
|
- text: <code>lascii</code> debería ser una función.
|
||
|
testString: 'assert(typeof lascii=="function","<code>lascii</code> should be a function.");'
|
||
|
- text: <code>lascii("a","d")</code> debe devolver una matriz.
|
||
|
testString: 'assert(Array.isArray(lascii("a","d")),"<code>lascii("a","d")</code> should return an array.");'
|
||
|
- text: '" <code>lascii("a","d")</code> debe devolver <code>[ "a", "b", "c", "d" ]</code> ."'
|
||
|
testString: 'assert.deepEqual(lascii("a","d"),results[0],"<code>lascii("a","d")</code> should return <code>[ "a", "b", "c", "d" ]</code>.");'
|
||
|
- text: '" <code>lascii("c","i")</code> debe devolver <code>[ "c", "d", "e", "f", "g", "h", "i" ]</code> ."'
|
||
|
testString: 'assert.deepEqual(lascii("c","i"),results[1],"<code>lascii("c","i")</code> should return <code>[ "c", "d", "e", "f", "g", "h", "i" ]</code>.");'
|
||
|
- text: '" <code>lascii("m","q")</code> debe devolver <code>[ "m", "n", "o", "p", "q" ]</code> ."'
|
||
|
testString: 'assert.deepEqual(lascii("m","q"),results[2],"<code>lascii("m","q")</code> should return <code>[ "m", "n", "o", "p", "q" ]</code>.");'
|
||
|
- text: '" <code>lascii("k","n")</code> debe devolver <code>[ "k", "l", "m", "n" ]</code> .")'
|
||
|
testString: 'assert.deepEqual(lascii("k","n"),results[3],"<code>lascii("k","n")</code> should return <code>[ "k", "l", "m", "n" ]</code>.");'
|
||
|
- text: '" <code>lascii("t","z")</code> debe devolver <code>[ "t", "u", "v", "w", "x", "y", "z" ]</code> ."'
|
||
|
testString: 'assert.deepEqual(lascii("t","z"),results[4],"<code>lascii("t","z")</code> should return <code>[ "t", "u", "v", "w", "x", "y", "z" ]</code>.");'
|
||
|
|
||
|
```
|
||
|
|
||
|
</section>
|
||
|
|
||
|
## Challenge Seed
|
||
|
<section id='challengeSeed'>
|
||
|
|
||
|
<div id='js-seed'>
|
||
|
|
||
|
```js
|
||
|
function lascii (cFrom, cTo) {
|
||
|
// Good luck!
|
||
|
}
|
||
|
```
|
||
|
|
||
|
</div>
|
||
|
|
||
|
|
||
|
### After Test
|
||
|
<div id='js-teardown'>
|
||
|
|
||
|
```js
|
||
|
console.info('after the test');
|
||
|
```
|
||
|
|
||
|
</div>
|
||
|
|
||
|
</section>
|
||
|
|
||
|
## Solution
|
||
|
<section id='solution'>
|
||
|
|
||
|
|
||
|
```js
|
||
|
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);
|
||
|
|
||
|
}
|
||
|
|
||
|
```
|
||
|
|
||
|
</section>
|