diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-data-structures/copy-an-array-with-the-spread-operator.english.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-data-structures/copy-an-array-with-the-spread-operator.english.md index 0fb2c32cc7..4dc22dca24 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-data-structures/copy-an-array-with-the-spread-operator.english.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-data-structures/copy-an-array-with-the-spread-operator.english.md @@ -22,15 +22,15 @@ We have defined a function, copyMachine which takes arrcopyMachine([true, false, true], 2) should return [[true, false, true], [true, false, true]] - testString: assert.deepEqual(copyMachine([true, false, true], 2), [[true, false, true], [true, false, true]], 'copyMachine([true, false, true], 2) should return [[true, false, true], [true, false, true]]'); + testString: assert.deepEqual(copyMachine([true, false, true], 2), [[true, false, true], [true, false, true]]); - text: copyMachine([1, 2, 3], 5) should return [[1, 2, 3], [1, 2, 3], [1, 2, 3], [1, 2, 3], [1, 2, 3]] - testString: assert.deepEqual(copyMachine([1, 2, 3], 5), [[1, 2, 3], [1, 2, 3], [1, 2, 3], [1, 2, 3], [1, 2, 3]], 'copyMachine([1, 2, 3], 5) should return [[1, 2, 3], [1, 2, 3], [1, 2, 3], [1, 2, 3], [1, 2, 3]]'); + testString: assert.deepEqual(copyMachine([1, 2, 3], 5), [[1, 2, 3], [1, 2, 3], [1, 2, 3], [1, 2, 3], [1, 2, 3]]); - text: copyMachine([true, true, null], 1) should return [[true, true, null]] - testString: assert.deepEqual(copyMachine([true, true, null], 1), [[true, true, null]], 'copyMachine([true, true, null], 1) should return [[true, true, null]]'); + testString: assert.deepEqual(copyMachine([true, true, null], 1), [[true, true, null]]); - text: copyMachine(["it works"], 3) should return [["it works"], ["it works"], ["it works"]] - testString: assert.deepEqual(copyMachine(['it works'], 3), [['it works'], ['it works'], ['it works']], 'copyMachine(["it works"], 3) should return [["it works"], ["it works"], ["it works"]]'); + testString: assert.deepEqual(copyMachine(['it works'], 3), [['it works'], ['it works'], ['it works']]); - text: The copyMachine function should utilize the spread operator with array arr - testString: assert.notStrictEqual(copyMachine.toString().indexOf('.concat(_toConsumableArray(arr))'), -1, 'The copyMachine function should utilize the spread operator with array arr'); + testString: assert(removeJSComments(code).match(/\.\.\.arr/)); ``` @@ -59,7 +59,14 @@ console.log(copyMachine([true, false, true], 2)); +### After Test +
+```js +const removeJSComments = str => str.replace(/\/\*[\s\S]*?\*\/|\/\/.*$/gm, ''); +``` + +
@@ -67,6 +74,16 @@ console.log(copyMachine([true, false, true], 2));
```js -// solution required +function copyMachine(arr,num){ + let newArr=[]; + while(num >=1){ + // change code below this line + newArr.push([...arr]); + //change code above this line + num--; + } + return newArr; +} +console.log(copyMachine([true, false, true], 2)); ```