From 6c38557ed9e6176e9c43da239ee3fd3d903c6053 Mon Sep 17 00:00:00 2001 From: Jessica Wilkins <67210629+jdwilkin4@users.noreply.github.com> Date: Wed, 21 May 2025 11:40:23 -0700 Subject: [PATCH] feat(curriculum): add sum all numbers algorithm (#60409) Co-authored-by: Dario-DC <105294544+Dario-DC@users.noreply.github.com> Co-authored-by: moT01 <20648924+moT01@users.noreply.github.com> --- client/i18n/locales/english/intro.json | 6 ++ .../lab-sum-all-numbers-algorithm/index.md | 9 +++ .../lab-sum-all-numbers-algorithm/meta.json | 11 +++ .../a3566b1109230028080c9345.md | 78 +++++++++++++++++++ .../superblock-structure/full-stack.json | 3 + curriculum/test/utils/mongo-ids.js | 4 + 6 files changed, 111 insertions(+) create mode 100644 client/src/pages/learn/full-stack-developer/lab-sum-all-numbers-algorithm/index.md create mode 100644 curriculum/challenges/_meta/lab-sum-all-numbers-algorithm/meta.json create mode 100644 curriculum/challenges/english/25-front-end-development/lab-sum-all-numbers-algorithm/a3566b1109230028080c9345.md diff --git a/client/i18n/locales/english/intro.json b/client/i18n/locales/english/intro.json index 260b378582c..25b1f4e4c67 100644 --- a/client/i18n/locales/english/intro.json +++ b/client/i18n/locales/english/intro.json @@ -2973,6 +2973,12 @@ "In this lab, you'll build a password generator app based on the user's input." ] }, + "lab-sum-all-numbers-algorithm": { + "title": "Design a Sum All Numbers Algorithm", + "intro": [ + "In this lab, you will design a sum all numbers algorithm. This algorithm takes an array of two numbers and returns the sum of those two numbers plus the sum of all the numbers between them." + ] + }, "review-javascript-fundamentals": { "title": "JavaScript Fundamentals Review", "intro": [ diff --git a/client/src/pages/learn/full-stack-developer/lab-sum-all-numbers-algorithm/index.md b/client/src/pages/learn/full-stack-developer/lab-sum-all-numbers-algorithm/index.md new file mode 100644 index 00000000000..9079256c91f --- /dev/null +++ b/client/src/pages/learn/full-stack-developer/lab-sum-all-numbers-algorithm/index.md @@ -0,0 +1,9 @@ +--- +title: Introduction to the Design a Sum All Numbers Algorithm +block: lab-sum-all-numbers-algorithm +superBlock: full-stack-developer +--- + +## Introduction to the Design a Sum All Numbers Algorithm + +In this lab, you will design a sum all numbers algorithm. This algorithm takes an array of two numbers and returns the sum of those two numbers plus the sum of all the numbers between them. diff --git a/curriculum/challenges/_meta/lab-sum-all-numbers-algorithm/meta.json b/curriculum/challenges/_meta/lab-sum-all-numbers-algorithm/meta.json new file mode 100644 index 00000000000..f840e0b8dc8 --- /dev/null +++ b/curriculum/challenges/_meta/lab-sum-all-numbers-algorithm/meta.json @@ -0,0 +1,11 @@ +{ + "name": "Design a Sum All Numbers Algorithm", + "isUpcomingChange": false, + "usesMultifileEditor": true, + "blockType": "lab", + "blockLayout": "link", + "dashedName": "lab-sum-all-numbers-algorithm", + "superBlock": "full-stack-developer", + "challengeOrder": [{ "id": "a3566b1109230028080c9345", "title": "Design a Sum All Numbers Algorithm" }], + "helpCategory": "JavaScript" +} diff --git a/curriculum/challenges/english/25-front-end-development/lab-sum-all-numbers-algorithm/a3566b1109230028080c9345.md b/curriculum/challenges/english/25-front-end-development/lab-sum-all-numbers-algorithm/a3566b1109230028080c9345.md new file mode 100644 index 00000000000..b6da919836c --- /dev/null +++ b/curriculum/challenges/english/25-front-end-development/lab-sum-all-numbers-algorithm/a3566b1109230028080c9345.md @@ -0,0 +1,78 @@ +--- +id: a3566b1109230028080c9345 +title: Design a Sum All Numbers Algorithm +challengeType: 26 +dashedName: lab-sum-all-numbers-algorithm +--- + +# --description-- + +In this lab, you will need to design a sum all numbers algorithm. + +Fulfill the user stories below and get all the tests to pass to complete the lab. + +**User Stories:** + +1. You should have a function named `sumAll` that accepts an array of two numbers. +1. `sumAll([n, m])` should return the sum of `n` and `m` plus the sum of all the numbers between them. The lowest number will not always come first. For example, `sumAll([4,1])` should return `10` because sum of all the numbers between `1` and `4` (both inclusive) is `10`. + +# --hints-- + +You should have a function named `sumAll`. + +```js +assert.isFunction(sumAll); +``` + +`sumAll([1, 4])` should return a number. + +```js +assert.isNumber(sumAll([1, 4])); +``` + +`sumAll([1, 4])` should return `10`. + +```js +assert.equal(sumAll([1, 4]), 10); +``` + +`sumAll([4, 1])` should return `10`. + +```js +assert.equal(sumAll([4, 1]), 10); +``` + +`sumAll([5, 10])` should return `45`. + +```js +assert.equal(sumAll([5, 10]), 45); +``` + +`sumAll([10, 5])` should return `45`. + +```js +assert.equal(sumAll([10, 5]), 45); +``` + +# --seed-- + +## --seed-contents-- + +```js +``` + +# --solutions-- + +```js +function sumAll(arr) { + let sum = 0; + + arr.sort((a, b) => a - b); + + for (var i = arr[0]; i <= arr[1]; i++) { + sum += i; + } + + return sum; +} +``` diff --git a/curriculum/superblock-structure/full-stack.json b/curriculum/superblock-structure/full-stack.json index a013a599838..e9e4540ad88 100644 --- a/curriculum/superblock-structure/full-stack.json +++ b/curriculum/superblock-structure/full-stack.json @@ -716,6 +716,9 @@ { "dashedName": "lab-password-generator" }, + { + "dashedName": "lab-sum-all-numbers-algorithm" + }, { "dashedName": "review-javascript-fundamentals" }, diff --git a/curriculum/test/utils/mongo-ids.js b/curriculum/test/utils/mongo-ids.js index 75888c90c84..42682cf35b1 100644 --- a/curriculum/test/utils/mongo-ids.js +++ b/curriculum/test/utils/mongo-ids.js @@ -1042,6 +1042,10 @@ const duplicatedProjectIds = [ /*** JavaScript ***/ + // Sum all numbers in range challenge (used in JS fundamentals review module) + + 'a3566b1109230028080c9345', + // Local Storage ToDo App '64e4e4c4ec263b62ae7bf54d',