From 4ab1dd89263e65c4d2168beeefc6d2f5650e1fcf Mon Sep 17 00:00:00 2001 From: abe <37171082+KravMaguy@users.noreply.github.com> Date: Wed, 12 Oct 2022 13:00:24 -0700 Subject: [PATCH] fix(curriculum): recursion challenges that abuse global space (#47680) * fix: recursion challenges that abuse global space #43516 * fix challenge phrasing and create separate test * fix: challenges which pollute/impure functions should not pass * Update curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-algorithms-and-data-structures-projects/cash-register.md allow users to ab(use) global space in cash register Co-authored-by: Tom <20648924+moT01@users.noreply.github.com> * Update curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/build-a-roman-numeral-converter-project/roman-numeral-converter.md allow users to abuse global space in roman numeral converter Co-authored-by: Tom <20648924+moT01@users.noreply.github.com> Co-authored-by: kravmaguy Co-authored-by: Tom <20648924+moT01@users.noreply.github.com> --- .../use-recursion-to-create-a-countdown.md | 7 +++++++ .../use-recursion-to-create-a-range-of-numbers.md | 7 +++++++ .../intermediate-algorithm-scripting/steamroller.md | 7 +++++++ 3 files changed, 21 insertions(+) diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/use-recursion-to-create-a-countdown.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/use-recursion-to-create-a-countdown.md index 7d2db2f3971..36dd7bcbf98 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/use-recursion-to-create-a-countdown.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/use-recursion-to-create-a-countdown.md @@ -71,6 +71,13 @@ assert( ); ``` +Global variables should not be used to cache the array. + +```js +countdown(1) +assert.deepStrictEqual(countdown(5), [5, 4, 3, 2, 1]); +``` + # --seed-- ## --seed-contents-- diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/use-recursion-to-create-a-range-of-numbers.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/use-recursion-to-create-a-range-of-numbers.md index 1d4b36878db..c1d664f2baf 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/use-recursion-to-create-a-range-of-numbers.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/use-recursion-to-create-a-range-of-numbers.md @@ -56,6 +56,13 @@ assert.deepStrictEqual(rangeOfNumbers(6, 9), [6, 7, 8, 9]); assert.deepStrictEqual(rangeOfNumbers(4, 4), [4]); ``` +Global variables should not be used to cache the array. + +```js +rangeOfNumbers(1, 3) +assert.deepStrictEqual(rangeOfNumbers(6, 9), [6, 7, 8, 9]); +``` + # --seed-- ## --seed-contents-- diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/steamroller.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/steamroller.md index 478b241b8bd..e0538763619 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/steamroller.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/steamroller.md @@ -42,6 +42,13 @@ Your solution should not use the `Array.prototype.flat()` or `Array.prototype.fl assert(!code.match(/\.\s*flat\s*\(/) && !code.match(/\.\s*flatMap\s*\(/)); ``` +Global variables should not be used. + +```js +steamrollArray([1, {}, [3, [[4]]]]) +assert.deepEqual(steamrollArray([1, {}, [3, [[4]]]]), [1, {}, 3, 4]) +``` + # --seed-- ## --seed-contents--