Skip to content

Commit c35dc47

Browse files
authored
feat(curriculum): add array shopping list workshop (freeCodeCamp#55939)
1 parent 0932ec7 commit c35dc47

23 files changed

+1331
-1
lines changed

client/i18n/locales/english/intro.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1924,7 +1924,13 @@
19241924
"avln": { "title": "157", "intro": [] },
19251925
"mexq": { "title": "158", "intro": [] },
19261926
"ifgn": { "title": "159", "intro": [] },
1927-
"qmdt": { "title": "160", "intro": [] },
1927+
"workshop-shopping-list": {
1928+
"title": "Build a Shopping List",
1929+
"intro": [
1930+
"In this workshop, you will practice working with arrays by building a shopping list.",
1931+
"You will review how to add and remove elements from an array using methods like <code>push</code>, <code>pop</code>, <code>shift</code>, and <code>unshift</code>."
1932+
]
1933+
},
19281934
"mokm": { "title": "161", "intro": [] },
19291935
"froz": { "title": "162", "intro": [] },
19301936
"ozth": { "title": "163", "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 Build a Shopping List
3+
block: workshop-shopping-list
4+
superBlock: front-end-development
5+
---
6+
7+
## Introduction to the Build a Shopping List
8+
9+
This is a test for the new project-based curriculum.
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
{
2+
"name": "Build a Shopping List",
3+
"blockType": "workshop",
4+
"isUpcomingChange": true,
5+
"usesMultifileEditor": true,
6+
"hasEditableBoundaries": true,
7+
"dashedName": "workshop-shopping-list",
8+
"order": 155,
9+
"superBlock": "front-end-development",
10+
"challengeOrder": [
11+
{
12+
"id": "66c63bfa4685e4e3843fa0dc",
13+
"title": "Step 1"
14+
},
15+
{
16+
"id": "66c64095f61166ede6e39a84",
17+
"title": "Step 2"
18+
},
19+
{
20+
"id": "66c64210413532ee9d3bd342",
21+
"title": "Step 3"
22+
},
23+
{
24+
"id": "66c644c08ebcd2ef90c750bd",
25+
"title": "Step 4"
26+
},
27+
{
28+
"id": "66c645b345a39bf04864dc50",
29+
"title": "Step 5"
30+
},
31+
{
32+
"id": "66cbe2319d3845545a293a0b",
33+
"title": "Step 6"
34+
},
35+
{
36+
"id": "66c6491fe4c8e0f16845425f",
37+
"title": "Step 7"
38+
},
39+
{
40+
"id": "66c64ad16796c7f2419b45c5",
41+
"title": "Step 8"
42+
},
43+
{
44+
"id": "66c726c34ecf1e238aa9d7d5",
45+
"title": "Step 9"
46+
},
47+
{
48+
"id": "66c72a55418cc9247b710827",
49+
"title": "Step 10"
50+
},
51+
{
52+
"id": "66c72b0ffbc5522525768558",
53+
"title": "Step 11"
54+
},
55+
{
56+
"id": "66c72f4d0528bd268a82107b",
57+
"title": "Step 12"
58+
},
59+
{
60+
"id": "66c730183f4020275cbf0611",
61+
"title": "Step 13"
62+
},
63+
{
64+
"id": "66c730ee6ae076281721d0b9",
65+
"title": "Step 14"
66+
},
67+
{
68+
"id": "66c73a0c5b264f2a75164d94",
69+
"title": "Step 15"
70+
},
71+
{
72+
"id": "66c73a7798f6f62b2ae58f22",
73+
"title": "Step 16"
74+
},
75+
{
76+
"id": "66c73fa7433e082c4be096b1",
77+
"title": "Step 17"
78+
},
79+
{
80+
"id": "66c74079c30b1c2d166cb9a4",
81+
"title": "Step 18"
82+
},
83+
{
84+
"id": "66c742d045c9fc2e09fa64b1",
85+
"title": "Step 19"
86+
},
87+
{
88+
"id": "66c748ffdfbe4f2ede268be2",
89+
"title": "Step 20"
90+
}
91+
],
92+
"helpCategory": "JavaScript"
93+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
---
2+
id: 66c63bfa4685e4e3843fa0dc
3+
title: Step 1
4+
challengeType: 1
5+
dashedName: step-1
6+
---
7+
8+
# --description--
9+
10+
In this workshop, you will continue to learn about arrays by building a grocery shopping list.
11+
12+
Start by adding a `console.log` that logs the string `"Grocery shopping list"` to the console.
13+
14+
# --hints--
15+
16+
You should have a `console.log` in your code.
17+
18+
```js
19+
assert.match(code, /console\.log(.*)/);
20+
```
21+
22+
Your `console.log` should output the message `"Grocery shopping list"`. Double check for spelling and capitalization errors.
23+
24+
```js
25+
assert.match(code, /console\.log\((["'])(Grocery\s+shopping\s+list)\1\)/);
26+
```
27+
28+
# --seed--
29+
30+
## --seed-contents--
31+
32+
```js
33+
--fcc-editable-region--
34+
35+
--fcc-editable-region--
36+
```
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
---
2+
id: 66c64095f61166ede6e39a84
3+
title: Step 2
4+
challengeType: 1
5+
dashedName: step-2
6+
---
7+
8+
# --description--
9+
10+
For this shopping list, you will use an array to represent the items you need to buy.
11+
12+
In the previous lecture videos, you learned how to create arrays like this:
13+
14+
```js
15+
const fruits = ['apple', 'banana', 'orange'];
16+
```
17+
18+
In this step, create a variable called `shoppingList` and assign it an empty array.
19+
20+
# --hints--
21+
22+
You should have a variable called `shoppingList`.
23+
24+
```js
25+
assert.isNotNull(shoppingList);
26+
```
27+
28+
You should assign an array to the `shoppingList` variable.
29+
30+
```js
31+
assert.isArray(shoppingList);
32+
```
33+
34+
Your array should be empty.
35+
36+
```js
37+
assert.isEmpty(shoppingList);
38+
```
39+
40+
# --seed--
41+
42+
## --seed-contents--
43+
44+
```js
45+
console.log("Grocery shopping list");
46+
47+
--fcc-editable-region--
48+
49+
--fcc-editable-region--
50+
```
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
---
2+
id: 66c64210413532ee9d3bd342
3+
title: Step 3
4+
challengeType: 1
5+
dashedName: step-3
6+
---
7+
8+
# --description--
9+
10+
For this next portion of the workshop, you will practice adding food items to the grocery list.
11+
12+
Start by using `console.log` to log the message `"It will be nice to have some fruit to eat."`.
13+
14+
# --hints--
15+
16+
You should log the message `"It will be nice to have some fruit to eat."` to the console.
17+
18+
```js
19+
assert.match(code, /console\.log\s*\(\s*(['"])(It\s+will\s+be\s+nice\s+to\s+have\s+some\s+fruit\s+to\s+eat\.)\1\s*\)\s*;?/);
20+
```
21+
22+
# --seed--
23+
24+
## --seed-contents--
25+
26+
```js
27+
console.log("Grocery shopping list");
28+
29+
const shoppingList = [];
30+
31+
--fcc-editable-region--
32+
33+
--fcc-editable-region--
34+
```
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
---
2+
id: 66c644c08ebcd2ef90c750bd
3+
title: Step 4
4+
challengeType: 1
5+
dashedName: step-4
6+
---
7+
8+
# --description--
9+
10+
In the previous lecture videos, you learned how to add items to the end of an array using the `push` method like this:
11+
12+
```js
13+
fruits.push('pear');
14+
```
15+
16+
Using the `push` method, add the string `"Apples"` to the `shoppingList` array.
17+
18+
# --hints--
19+
20+
Your `shoppingList` array should have one item in it.
21+
22+
```js
23+
assert.lengthOf(shoppingList, 1);
24+
```
25+
26+
Your `shoppingList` array should have the string `"Apples"` in it. Double check for spelling and capitalization errors.
27+
28+
```js
29+
assert.includeMembers(shoppingList, ['Apples']);
30+
```
31+
32+
# --seed--
33+
34+
## --seed-contents--
35+
36+
```js
37+
console.log("Grocery shopping list");
38+
39+
const shoppingList = [];
40+
41+
console.log("It will be nice to have some fruit to eat.");
42+
43+
--fcc-editable-region--
44+
45+
--fcc-editable-region--
46+
```
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
---
2+
id: 66c645b345a39bf04864dc50
3+
title: Step 5
4+
challengeType: 1
5+
dashedName: step-5
6+
---
7+
8+
# --description--
9+
10+
To see the updated shopping list, you will need to log the current shopping list and a short message to the console.
11+
12+
Since this message will be used repeatedly throughout the workshop, it is best to create a reusable function.
13+
14+
Create a function called `getShoppingListMsg` that returns the string `"Current Shopping List: "` followed by the `shoppingList` array.
15+
16+
You can use template literals or string concatenation with the `+` operator to combine the string and the `shoppingList` array.
17+
18+
# --hints--
19+
20+
You should have a function called `getShoppingListMsg` in your code.
21+
22+
```js
23+
assert.isFunction(getShoppingListMsg);
24+
```
25+
26+
Your `getShoppingListMsg` function should return a string.
27+
28+
```js
29+
assert.isString(getShoppingListMsg());
30+
```
31+
32+
Your `getShoppingListMsg` function should return the message of `"Current Shopping List: "` followed by the `shoppingList` array. Double check spacing and spelling errors.
33+
34+
```js
35+
assert.strictEqual(getShoppingListMsg(), "Current Shopping List: Apples");
36+
```
37+
38+
# --seed--
39+
40+
## --seed-contents--
41+
42+
```js
43+
console.log("Grocery shopping list");
44+
45+
const shoppingList = [];
46+
47+
console.log("It will be nice to have some fruit to eat.");
48+
49+
shoppingList.push("Apples");
50+
51+
--fcc-editable-region--
52+
53+
--fcc-editable-region--
54+
```

0 commit comments

Comments
 (0)