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>
This commit is contained in:
Ilenia
2025-05-28 16:58:09 +02:00
committed by GitHub
parent 466e720812
commit 86b76f2eec
9 changed files with 285 additions and 1 deletions

View File

@@ -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": [

View File

@@ -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.

View File

@@ -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.

View File

@@ -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"
}

View File

@@ -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"
}

View File

@@ -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);
```

View File

@@ -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']);
```

View File

@@ -684,6 +684,8 @@
{
"dashedName": "lab-factorial-calculator"
},
{ "dashedName": "lab-mutations" },
{ "dashedName": "lab-chunky-monkey" },
{
"dashedName": "review-javascript-loops"
},

View File

@@ -1521,11 +1521,14 @@ const duplicatedProjectIds = [
'5e44413e903586ffb414c94e',
// Polygon area calculator
'5e444147903586ffb414c94f'
'5e444147903586ffb414c94f',
/*** Back End JavaScript ***/
/*** Legacy Only ***/
'a9bd25c716030ec90084d8a1',
'af2170cad53daa0770fabdea'
];
class MongoIds {