From 86b76f2eecf32cf2cfa4986da4aded1db1129295 Mon Sep 17 00:00:00 2001 From: Ilenia <26656284+ilenia-magoni@users.noreply.github.com> Date: Wed, 28 May 2025 16:58:09 +0200 Subject: [PATCH] chore(curriculum): add two labs to full stack/javascript/loops (#60185) Co-authored-by: Dario-DC <105294544+Dario-DC@users.noreply.github.com> Co-authored-by: Kolade Chris <65571316+Ksound22@users.noreply.github.com> --- client/i18n/locales/english/intro.json | 12 ++ .../lab-chunky-monkey/index.md | 9 ++ .../lab-mutations/index.md | 9 ++ .../_meta/lab-chunky-monkey/meta.json | 11 ++ .../challenges/_meta/lab-mutations/meta.json | 11 ++ .../a9bd25c716030ec90084d8a1.md | 108 ++++++++++++++++ .../lab-mutations/af2170cad53daa0770fabdea.md | 119 ++++++++++++++++++ .../superblock-structure/full-stack.json | 2 + curriculum/test/utils/mongo-ids.js | 5 +- 9 files changed, 285 insertions(+), 1 deletion(-) create mode 100644 client/src/pages/learn/full-stack-developer/lab-chunky-monkey/index.md create mode 100644 client/src/pages/learn/full-stack-developer/lab-mutations/index.md create mode 100644 curriculum/challenges/_meta/lab-chunky-monkey/meta.json create mode 100644 curriculum/challenges/_meta/lab-mutations/meta.json create mode 100644 curriculum/challenges/english/25-front-end-development/lab-chunky-monkey/a9bd25c716030ec90084d8a1.md create mode 100644 curriculum/challenges/english/25-front-end-development/lab-mutations/af2170cad53daa0770fabdea.md diff --git a/client/i18n/locales/english/intro.json b/client/i18n/locales/english/intro.json index ef64a36daa3..d2fb4026586 100644 --- a/client/i18n/locales/english/intro.json +++ b/client/i18n/locales/english/intro.json @@ -2927,6 +2927,18 @@ "You'll practice using loops and conditionals to calculate the factorial of a number." ] }, + "lab-mutations": { + "title": "Implement the Mutations Algorithm", + "intro": [ + "In this lab, you will practice iterating over two different strings to compare their characters." + ] + }, + "lab-chunky-monkey": { + "title": "Implement the Chunky Monkey Algorithm", + "intro": [ + "In this lab, you will practice dividing an array into smaller arrays with the technique of your choice." + ] + }, "review-javascript-loops": { "title": "JavaScript Loops Review", "intro": [ diff --git a/client/src/pages/learn/full-stack-developer/lab-chunky-monkey/index.md b/client/src/pages/learn/full-stack-developer/lab-chunky-monkey/index.md new file mode 100644 index 00000000000..abfcea2ea0e --- /dev/null +++ b/client/src/pages/learn/full-stack-developer/lab-chunky-monkey/index.md @@ -0,0 +1,9 @@ +--- +title: Introduction to the Chunky Monkey Algorithm +block: lab-chunky-monkey +superBlock: full-stack-developer +--- + +## Introduction to the Chunky Monkey Algorithm + +This lab will focus on dividing an array into smaller arrays. diff --git a/client/src/pages/learn/full-stack-developer/lab-mutations/index.md b/client/src/pages/learn/full-stack-developer/lab-mutations/index.md new file mode 100644 index 00000000000..74a9cf89081 --- /dev/null +++ b/client/src/pages/learn/full-stack-developer/lab-mutations/index.md @@ -0,0 +1,9 @@ +--- +title: Introduction to the Mutations Algorithm +block: lab-mutations +superBlock: full-stack-developer +--- + +## Introduction to the Mutations Algorithm + +This lab will focus on iterating over two strings to compare their characters. diff --git a/curriculum/challenges/_meta/lab-chunky-monkey/meta.json b/curriculum/challenges/_meta/lab-chunky-monkey/meta.json new file mode 100644 index 00000000000..3348b2bf84a --- /dev/null +++ b/curriculum/challenges/_meta/lab-chunky-monkey/meta.json @@ -0,0 +1,11 @@ +{ + "name": "Implement the Chunky Monkey Algorithm", + "blockType": "lab", + "blockLayout": "link", + "isUpcomingChange": false, + "usesMultifileEditor": true, + "dashedName": "lab-chunky-monkey", + "superBlock": "full-stack-developer", + "challengeOrder": [{ "id": "a9bd25c716030ec90084d8a1", "title": "Implement the Chunky Monkey Algorithm" }], + "helpCategory": "JavaScript" +} diff --git a/curriculum/challenges/_meta/lab-mutations/meta.json b/curriculum/challenges/_meta/lab-mutations/meta.json new file mode 100644 index 00000000000..beaab15ff93 --- /dev/null +++ b/curriculum/challenges/_meta/lab-mutations/meta.json @@ -0,0 +1,11 @@ +{ + "name": "Implement the Mutations Algorithm", + "blockType": "lab", + "blockLayout": "link", + "isUpcomingChange": false, + "usesMultifileEditor": true, + "dashedName": "lab-mutations", + "superBlock": "full-stack-developer", + "challengeOrder": [{ "id": "af2170cad53daa0770fabdea", "title": "Implement the Mutations Algorithm" }], + "helpCategory": "JavaScript" +} diff --git a/curriculum/challenges/english/25-front-end-development/lab-chunky-monkey/a9bd25c716030ec90084d8a1.md b/curriculum/challenges/english/25-front-end-development/lab-chunky-monkey/a9bd25c716030ec90084d8a1.md new file mode 100644 index 00000000000..75edbf3d789 --- /dev/null +++ b/curriculum/challenges/english/25-front-end-development/lab-chunky-monkey/a9bd25c716030ec90084d8a1.md @@ -0,0 +1,108 @@ +--- +id: a9bd25c716030ec90084d8a1 +title: Implement the Chunky Monkey Algorithm +challengeType: 26 +dashedName: implement-the-chunky-monkey-algorithm +--- + +# --description-- + +Fulfill the user stories below and get all the tests to pass to complete the lab. + +**User Stories:** + +1. Write a function named `chunkArrayInGroups` that takes an array as first argument and a number as second argument. The function should split the array into smaller arrays of length equal to the second argument and returns them as a two-dimensional array. + +# --hints-- + +`chunkArrayInGroups(["a", "b", "c", "d"], 2)` should return `[["a", "b"], ["c", "d"]]`. + +```js +assert.deepEqual(chunkArrayInGroups(['a', 'b', 'c', 'd'], 2), [ + ['a', 'b'], + ['c', 'd'] +]); +``` + +`chunkArrayInGroups([0, 1, 2, 3, 4, 5], 3)` should return `[[0, 1, 2], [3, 4, 5]]`. + +```js +assert.deepEqual(chunkArrayInGroups([0, 1, 2, 3, 4, 5], 3), [ + [0, 1, 2], + [3, 4, 5] +]); +``` + +`chunkArrayInGroups([0, 1, 2, 3, 4, 5], 2)` should return `[[0, 1], [2, 3], [4, 5]]`. + +```js +assert.deepEqual(chunkArrayInGroups([0, 1, 2, 3, 4, 5], 2), [ + [0, 1], + [2, 3], + [4, 5] +]); +``` + +`chunkArrayInGroups([0, 1, 2, 3, 4, 5], 4)` should return `[[0, 1, 2, 3], [4, 5]]`. + +```js +assert.deepEqual(chunkArrayInGroups([0, 1, 2, 3, 4, 5], 4), [ + [0, 1, 2, 3], + [4, 5] +]); +``` + +`chunkArrayInGroups([0, 1, 2, 3, 4, 5, 6], 3)` should return `[[0, 1, 2], [3, 4, 5], [6]]`. + +```js +assert.deepEqual(chunkArrayInGroups([0, 1, 2, 3, 4, 5, 6], 3), [ + [0, 1, 2], + [3, 4, 5], + [6] +]); +``` + +`chunkArrayInGroups([0, 1, 2, 3, 4, 5, 6, 7, 8], 4)` should return `[[0, 1, 2, 3], [4, 5, 6, 7], [8]]`. + +```js +assert.deepEqual(chunkArrayInGroups([0, 1, 2, 3, 4, 5, 6, 7, 8], 4), [ + [0, 1, 2, 3], + [4, 5, 6, 7], + [8] +]); +``` + +`chunkArrayInGroups([0, 1, 2, 3, 4, 5, 6, 7, 8], 2)` should return `[[0, 1], [2, 3], [4, 5], [6, 7], [8]]`. + +```js +assert.deepEqual(chunkArrayInGroups([0, 1, 2, 3, 4, 5, 6, 7, 8], 2), [ + [0, 1], + [2, 3], + [4, 5], + [6, 7], + [8] +]); +``` + +# --seed-- + +## --seed-contents-- + +```js +``` + +# --solutions-- + +```js +function chunkArrayInGroups(arr, size) { + let out = []; + + for (let i = 0; i < arr.length; i += size) { + out.push(arr.slice(i, i + size)); + } + + return out; +} + +chunkArrayInGroups(['a', 'b', 'c', 'd'], 2); +``` diff --git a/curriculum/challenges/english/25-front-end-development/lab-mutations/af2170cad53daa0770fabdea.md b/curriculum/challenges/english/25-front-end-development/lab-mutations/af2170cad53daa0770fabdea.md new file mode 100644 index 00000000000..57fd2e3c502 --- /dev/null +++ b/curriculum/challenges/english/25-front-end-development/lab-mutations/af2170cad53daa0770fabdea.md @@ -0,0 +1,119 @@ +--- +id: af2170cad53daa0770fabdea +title: Implement the Mutations Algorithm +challengeType: 26 +dashedName: implement-the-mutations-algorithm +--- + +# --description-- + +Fulfill the user stories below and get all the tests to pass to complete the lab. + +**User Stories:** + +1. Create a function named `mutation` that takes an array as its argument. +1. `mutation` should return `true` if the string in the first element of the array contains all of the letters of the string in the second element of the array, and `false` otherwise. For example: + - `mutation(["hello", "Hello"])`, should return `true` because all of the letters in the second string are present in the first, ignoring case. + - `mutation(["hello", "hey"])` should return `false` because the string `hello` does not contain a `y`. + - `mutation(["Alien", "line"])`, should return `true` because all of the letters in `line` are present in `Alien`. + +# --hints-- + +`mutation(["hello", "hey"])` should return `false`. + +```js +assert.isFalse(mutation(['hello', 'hey'])); +``` + +`mutation(["hello", "Hello"])` should return `true`. + +```js +assert.isTrue(mutation(['hello', 'Hello'])); +``` + +`mutation(["zyxwvutsrqponmlkjihgfedcba", "qrstu"])` should return `true`. + +```js +assert.isTrue(mutation(['zyxwvutsrqponmlkjihgfedcba', 'qrstu'])); +``` + +`mutation(["Mary", "Army"])` should return `true`. + +```js +assert.isTrue(mutation(['Mary', 'Army'])); +``` + +`mutation(["Mary", "Aarmy"])` should return `true`. + +```js +assert.isTrue(mutation(['Mary', 'Aarmy'])); +``` + +`mutation(["Alien", "line"])` should return `true`. + +```js +assert.isTrue(mutation(['Alien', 'line'])); +``` + +`mutation(["floor", "for"])` should return `true`. + +```js +assert.isTrue(mutation(['floor', 'for'])); +``` + +`mutation(["hello", "neo"])` should return `false`. + +```js +assert.isFalse(mutation(['hello', 'neo'])); +``` + +`mutation(["voodoo", "no"])` should return `false`. + +```js +assert.isFalse(mutation(['voodoo', 'no'])); +``` + +`mutation(["ate", "date"])` should return `false`. + +```js +assert.isFalse(mutation(['ate', 'date'])); +``` + +`mutation(["Tiger", "Zebra"])` should return `false`. + +```js +assert.isFalse(mutation(['Tiger', 'Zebra'])); +``` + +`mutation(["Noel", "Ole"])` should return `true`. + +```js +assert.isTrue(mutation(['Noel', 'Ole'])); +``` + +# --seed-- + +## --seed-contents-- + +```js +``` + +# --solutions-- + +```js +function mutation(arr) { + let hash = Object.create(null); + + arr[0] + .toLowerCase() + .split('') + .forEach(c => (hash[c] = true)); + + return !arr[1] + .toLowerCase() + .split('') + .filter(c => !hash[c]).length; +} + +mutation(['hello', 'hey']); +``` diff --git a/curriculum/superblock-structure/full-stack.json b/curriculum/superblock-structure/full-stack.json index e9e4540ad88..7771530757b 100644 --- a/curriculum/superblock-structure/full-stack.json +++ b/curriculum/superblock-structure/full-stack.json @@ -684,6 +684,8 @@ { "dashedName": "lab-factorial-calculator" }, + { "dashedName": "lab-mutations" }, + { "dashedName": "lab-chunky-monkey" }, { "dashedName": "review-javascript-loops" }, diff --git a/curriculum/test/utils/mongo-ids.js b/curriculum/test/utils/mongo-ids.js index 42682cf35b1..c06eaef8860 100644 --- a/curriculum/test/utils/mongo-ids.js +++ b/curriculum/test/utils/mongo-ids.js @@ -1521,11 +1521,14 @@ const duplicatedProjectIds = [ '5e44413e903586ffb414c94e', // Polygon area calculator - '5e444147903586ffb414c94f' + '5e444147903586ffb414c94f', /*** Back End JavaScript ***/ /*** Legacy Only ***/ + + 'a9bd25c716030ec90084d8a1', + 'af2170cad53daa0770fabdea' ]; class MongoIds {