Skip to content

Commit 86b76f2

Browse files
majestic-owl448Dario-DCKsound22
authored
chore(curriculum): add two labs to full stack/javascript/loops (freeCodeCamp#60185)
Co-authored-by: Dario-DC <105294544+Dario-DC@users.noreply.github.com> Co-authored-by: Kolade Chris <65571316+Ksound22@users.noreply.github.com>
1 parent 466e720 commit 86b76f2

9 files changed

Lines changed: 285 additions & 1 deletion

File tree

client/i18n/locales/english/intro.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2927,6 +2927,18 @@
29272927
"You'll practice using loops and conditionals to calculate the factorial of a number."
29282928
]
29292929
},
2930+
"lab-mutations": {
2931+
"title": "Implement the Mutations Algorithm",
2932+
"intro": [
2933+
"In this lab, you will practice iterating over two different strings to compare their characters."
2934+
]
2935+
},
2936+
"lab-chunky-monkey": {
2937+
"title": "Implement the Chunky Monkey Algorithm",
2938+
"intro": [
2939+
"In this lab, you will practice dividing an array into smaller arrays with the technique of your choice."
2940+
]
2941+
},
29302942
"review-javascript-loops": {
29312943
"title": "JavaScript Loops Review",
29322944
"intro": [
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
title: Introduction to the Chunky Monkey Algorithm
3+
block: lab-chunky-monkey
4+
superBlock: full-stack-developer
5+
---
6+
7+
## Introduction to the Chunky Monkey Algorithm
8+
9+
This lab will focus on dividing an array into smaller arrays.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
title: Introduction to the Mutations Algorithm
3+
block: lab-mutations
4+
superBlock: full-stack-developer
5+
---
6+
7+
## Introduction to the Mutations Algorithm
8+
9+
This lab will focus on iterating over two strings to compare their characters.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"name": "Implement the Chunky Monkey Algorithm",
3+
"blockType": "lab",
4+
"blockLayout": "link",
5+
"isUpcomingChange": false,
6+
"usesMultifileEditor": true,
7+
"dashedName": "lab-chunky-monkey",
8+
"superBlock": "full-stack-developer",
9+
"challengeOrder": [{ "id": "a9bd25c716030ec90084d8a1", "title": "Implement the Chunky Monkey Algorithm" }],
10+
"helpCategory": "JavaScript"
11+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"name": "Implement the Mutations Algorithm",
3+
"blockType": "lab",
4+
"blockLayout": "link",
5+
"isUpcomingChange": false,
6+
"usesMultifileEditor": true,
7+
"dashedName": "lab-mutations",
8+
"superBlock": "full-stack-developer",
9+
"challengeOrder": [{ "id": "af2170cad53daa0770fabdea", "title": "Implement the Mutations Algorithm" }],
10+
"helpCategory": "JavaScript"
11+
}
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
---
2+
id: a9bd25c716030ec90084d8a1
3+
title: Implement the Chunky Monkey Algorithm
4+
challengeType: 26
5+
dashedName: implement-the-chunky-monkey-algorithm
6+
---
7+
8+
# --description--
9+
10+
Fulfill the user stories below and get all the tests to pass to complete the lab.
11+
12+
**User Stories:**
13+
14+
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.
15+
16+
# --hints--
17+
18+
`chunkArrayInGroups(["a", "b", "c", "d"], 2)` should return `[["a", "b"], ["c", "d"]]`.
19+
20+
```js
21+
assert.deepEqual(chunkArrayInGroups(['a', 'b', 'c', 'd'], 2), [
22+
['a', 'b'],
23+
['c', 'd']
24+
]);
25+
```
26+
27+
`chunkArrayInGroups([0, 1, 2, 3, 4, 5], 3)` should return `[[0, 1, 2], [3, 4, 5]]`.
28+
29+
```js
30+
assert.deepEqual(chunkArrayInGroups([0, 1, 2, 3, 4, 5], 3), [
31+
[0, 1, 2],
32+
[3, 4, 5]
33+
]);
34+
```
35+
36+
`chunkArrayInGroups([0, 1, 2, 3, 4, 5], 2)` should return `[[0, 1], [2, 3], [4, 5]]`.
37+
38+
```js
39+
assert.deepEqual(chunkArrayInGroups([0, 1, 2, 3, 4, 5], 2), [
40+
[0, 1],
41+
[2, 3],
42+
[4, 5]
43+
]);
44+
```
45+
46+
`chunkArrayInGroups([0, 1, 2, 3, 4, 5], 4)` should return `[[0, 1, 2, 3], [4, 5]]`.
47+
48+
```js
49+
assert.deepEqual(chunkArrayInGroups([0, 1, 2, 3, 4, 5], 4), [
50+
[0, 1, 2, 3],
51+
[4, 5]
52+
]);
53+
```
54+
55+
`chunkArrayInGroups([0, 1, 2, 3, 4, 5, 6], 3)` should return `[[0, 1, 2], [3, 4, 5], [6]]`.
56+
57+
```js
58+
assert.deepEqual(chunkArrayInGroups([0, 1, 2, 3, 4, 5, 6], 3), [
59+
[0, 1, 2],
60+
[3, 4, 5],
61+
[6]
62+
]);
63+
```
64+
65+
`chunkArrayInGroups([0, 1, 2, 3, 4, 5, 6, 7, 8], 4)` should return `[[0, 1, 2, 3], [4, 5, 6, 7], [8]]`.
66+
67+
```js
68+
assert.deepEqual(chunkArrayInGroups([0, 1, 2, 3, 4, 5, 6, 7, 8], 4), [
69+
[0, 1, 2, 3],
70+
[4, 5, 6, 7],
71+
[8]
72+
]);
73+
```
74+
75+
`chunkArrayInGroups([0, 1, 2, 3, 4, 5, 6, 7, 8], 2)` should return `[[0, 1], [2, 3], [4, 5], [6, 7], [8]]`.
76+
77+
```js
78+
assert.deepEqual(chunkArrayInGroups([0, 1, 2, 3, 4, 5, 6, 7, 8], 2), [
79+
[0, 1],
80+
[2, 3],
81+
[4, 5],
82+
[6, 7],
83+
[8]
84+
]);
85+
```
86+
87+
# --seed--
88+
89+
## --seed-contents--
90+
91+
```js
92+
```
93+
94+
# --solutions--
95+
96+
```js
97+
function chunkArrayInGroups(arr, size) {
98+
let out = [];
99+
100+
for (let i = 0; i < arr.length; i += size) {
101+
out.push(arr.slice(i, i + size));
102+
}
103+
104+
return out;
105+
}
106+
107+
chunkArrayInGroups(['a', 'b', 'c', 'd'], 2);
108+
```
Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
---
2+
id: af2170cad53daa0770fabdea
3+
title: Implement the Mutations Algorithm
4+
challengeType: 26
5+
dashedName: implement-the-mutations-algorithm
6+
---
7+
8+
# --description--
9+
10+
Fulfill the user stories below and get all the tests to pass to complete the lab.
11+
12+
**User Stories:**
13+
14+
1. Create a function named `mutation` that takes an array as its argument.
15+
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:
16+
- `mutation(["hello", "Hello"])`, should return `true` because all of the letters in the second string are present in the first, ignoring case.
17+
- `mutation(["hello", "hey"])` should return `false` because the string `hello` does not contain a `y`.
18+
- `mutation(["Alien", "line"])`, should return `true` because all of the letters in `line` are present in `Alien`.
19+
20+
# --hints--
21+
22+
`mutation(["hello", "hey"])` should return `false`.
23+
24+
```js
25+
assert.isFalse(mutation(['hello', 'hey']));
26+
```
27+
28+
`mutation(["hello", "Hello"])` should return `true`.
29+
30+
```js
31+
assert.isTrue(mutation(['hello', 'Hello']));
32+
```
33+
34+
`mutation(["zyxwvutsrqponmlkjihgfedcba", "qrstu"])` should return `true`.
35+
36+
```js
37+
assert.isTrue(mutation(['zyxwvutsrqponmlkjihgfedcba', 'qrstu']));
38+
```
39+
40+
`mutation(["Mary", "Army"])` should return `true`.
41+
42+
```js
43+
assert.isTrue(mutation(['Mary', 'Army']));
44+
```
45+
46+
`mutation(["Mary", "Aarmy"])` should return `true`.
47+
48+
```js
49+
assert.isTrue(mutation(['Mary', 'Aarmy']));
50+
```
51+
52+
`mutation(["Alien", "line"])` should return `true`.
53+
54+
```js
55+
assert.isTrue(mutation(['Alien', 'line']));
56+
```
57+
58+
`mutation(["floor", "for"])` should return `true`.
59+
60+
```js
61+
assert.isTrue(mutation(['floor', 'for']));
62+
```
63+
64+
`mutation(["hello", "neo"])` should return `false`.
65+
66+
```js
67+
assert.isFalse(mutation(['hello', 'neo']));
68+
```
69+
70+
`mutation(["voodoo", "no"])` should return `false`.
71+
72+
```js
73+
assert.isFalse(mutation(['voodoo', 'no']));
74+
```
75+
76+
`mutation(["ate", "date"])` should return `false`.
77+
78+
```js
79+
assert.isFalse(mutation(['ate', 'date']));
80+
```
81+
82+
`mutation(["Tiger", "Zebra"])` should return `false`.
83+
84+
```js
85+
assert.isFalse(mutation(['Tiger', 'Zebra']));
86+
```
87+
88+
`mutation(["Noel", "Ole"])` should return `true`.
89+
90+
```js
91+
assert.isTrue(mutation(['Noel', 'Ole']));
92+
```
93+
94+
# --seed--
95+
96+
## --seed-contents--
97+
98+
```js
99+
```
100+
101+
# --solutions--
102+
103+
```js
104+
function mutation(arr) {
105+
let hash = Object.create(null);
106+
107+
arr[0]
108+
.toLowerCase()
109+
.split('')
110+
.forEach(c => (hash[c] = true));
111+
112+
return !arr[1]
113+
.toLowerCase()
114+
.split('')
115+
.filter(c => !hash[c]).length;
116+
}
117+
118+
mutation(['hello', 'hey']);
119+
```

curriculum/superblock-structure/full-stack.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -684,6 +684,8 @@
684684
{
685685
"dashedName": "lab-factorial-calculator"
686686
},
687+
{ "dashedName": "lab-mutations" },
688+
{ "dashedName": "lab-chunky-monkey" },
687689
{
688690
"dashedName": "review-javascript-loops"
689691
},

curriculum/test/utils/mongo-ids.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1521,11 +1521,14 @@ const duplicatedProjectIds = [
15211521
'5e44413e903586ffb414c94e',
15221522

15231523
// Polygon area calculator
1524-
'5e444147903586ffb414c94f'
1524+
'5e444147903586ffb414c94f',
15251525

15261526
/*** Back End JavaScript ***/
15271527

15281528
/*** Legacy Only ***/
1529+
1530+
'a9bd25c716030ec90084d8a1',
1531+
'af2170cad53daa0770fabdea'
15291532
];
15301533

15311534
class MongoIds {

0 commit comments

Comments
 (0)