2.3 KiB
2.3 KiB
id, title, localeTitle, challengeType
id | title | localeTitle | challengeType |
---|---|---|---|
587d7b7b367417b2b2512b17 | Combine Arrays with the Spread Operator | Combina matrices con el operador de propagación | 1 |
Description
let thisArray = ['sage', 'rosemary', 'parsley', 'thyme'];Usando la sintaxis de propagación, acabamos de lograr una operación que hubiera sido más compleja y más detallada si hubiéramos usado métodos tradicionales.
let thatArray = ['basil', 'cilantro', ...thisArray, 'coriander'];
// thatArray now equals ['basil', 'cilantro', 'sage', 'rosemary', 'parsley', 'thyme', 'coriander']
Instructions
spreadOut
que devuelve la sentence
variable, modifique la función usando el operador de propagación para que devuelva la matriz ['learning', 'to', 'code', 'is', 'fun']
.
Tests
tests:
- text: ' <code>spreadOut</code> debería devolver <code>["learning", "to", "code", "is", "fun"]</code> '
testString: 'assert.deepEqual(spreadOut(), ["learning", "to", "code", "is", "fun"], "<code>spreadOut</code> should return <code>["learning", "to", "code", "is", "fun"]</code>");'
- text: La función <code>spreadOut</code> debe utilizar la sintaxis de difusión
testString: 'assert.notStrictEqual(spreadOut.toString().search(/[...]/), -1, "The <code>spreadOut</code> function should utilize spread syntax");'
Challenge Seed
function spreadOut() {
let fragment = ['to', 'code'];
let sentence; // change this line
return sentence;
}
// do not change code below this line
console.log(spreadOut());
Solution
// solution required