From c70b4beb8dfcd1875b6ad1cc7084a82dba334d9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lasse=20J=C3=B8rgensen?= <28780271+lasjorg@users.noreply.github.com> Date: Mon, 24 Jun 2024 11:07:46 +0200 Subject: [PATCH] fix(curriculum): log test, method return, example code (#55298) --- .../660f4de78f775e480ba2e451.md | 16 +++++++++++----- .../660f4e74f7fd3f4a99ac2e50.md | 2 -- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f4de78f775e480ba2e451.md b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f4de78f775e480ba2e451.md index 97455c29bd3..401a1b239dc 100644 --- a/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f4de78f775e480ba2e451.md +++ b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f4de78f775e480ba2e451.md @@ -7,15 +7,15 @@ dashedName: step-107 # --description-- -The `.unshift()` method of an array allows you to add a value to the **beginning** of the array, unlike `.push()` which adds the value at the end of the array. Here is an example: +The `.unshift()` method of an array allows you to add a value to the **beginning** of the array, unlike `.push()` which adds the value at the end of the array. `.unshift()` returns the new length of the array it was called on. ```js -const numbers = [1, 2, 3]; -numbers.unshift(5); +const countDown = [2, 1, 0]; +const newLength = countDown.unshift(3); +console.log(countDown); // [3, 2, 1, 0] +console.log(newLength); // 4 ``` -The `numbers` array would now be `[5, 1, 2, 3]`. - Use `const` to declare an `unshifted` variable, and assign it the result of calling `.unshift()` on your `numbers` array. Pass `5` as the argument. Then print your `unshifted` variable. # --hints-- @@ -44,6 +44,12 @@ You should assign the result of your `.unshift()` call to your `unshifted` varia assert.equal(unshifted, 4); ``` +You should log your `unshifted` variable. + +```js +assert.match(__helpers.removeJSComments(code), /console\.log\(\s*unshifted\s*\);?/); +``` + # --seed-- ## --seed-contents-- diff --git a/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f4e74f7fd3f4a99ac2e50.md b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f4e74f7fd3f4a99ac2e50.md index ec4a4405439..e77e32ef2eb 100644 --- a/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f4e74f7fd3f4a99ac2e50.md +++ b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f4e74f7fd3f4a99ac2e50.md @@ -7,8 +7,6 @@ dashedName: step-108 # --description-- -Notice that like `.push()`, `.unshift()` returns the new length of the array after the element is added. - Arrays also have a `.shift()` method. This will remove the **first** element of the array, unlike `.pop()` which removes the last element. Here is an example of the `.shift()` method: ```js