Skip to content

Commit a2480c2

Browse files
committed
Remove tuple exercise
1 parent e6a1c42 commit a2480c2

File tree

65 files changed

+126
-521
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+126
-521
lines changed

epicshop/post-set-playground.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,19 @@ for (const testFile of testFiles) {
3838

3939
fs.copyFileSync(src, dest)
4040
}
41+
42+
const tsconfigPath = path.join(destDir, 'tsconfig.json')
43+
44+
if (!fs.existsSync(tsconfigPath)) {
45+
fs.writeFileSync(
46+
tsconfigPath,
47+
JSON.stringify(
48+
{
49+
extends: '../tsconfig.json',
50+
include: ['**/*.ts', '**/*.tsx'],
51+
},
52+
null,
53+
2,
54+
) + '\n',
55+
)
56+
}

exercises/04.destructuring/01.problem.object-destructuring/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,5 @@ const user: User = {
3636
// console.log(bio) // 'No bio provided'
3737
// console.log(formatUserCard(user))
3838

39-
// 🐨 Export your variables and function so we can verify your work
39+
// 🐨 Export your variables and functi// 💰 exportcan verify your work
4040
// export { name, email, userId, bio, formatUserCard }

exercises/04.destructuring/02.problem.array-destructuring/README.mdx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Array Destructuring
22

33
👨‍💼 Array destructuring extracts elements by position. It's especially useful for
4-
working with tuples, function return values, and APIs that return arrays.
4+
working with function return values and APIs that return arrays.
55

66
```ts
77
const colors = ['red', 'green', 'blue']
@@ -47,6 +47,4 @@ let b = 2
4747
2. Use the rest pattern to separate the first item from the rest
4848
3. Create a function that returns multiple values and destructure the result
4949

50-
💰 The rest pattern can preserve types when used with tuples.
51-
5250
📜 [MDN - Destructuring Assignment](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment#array_destructuring)

exercises/04.destructuring/02.problem.array-destructuring/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Array Destructuring
22
// Extracting values from arrays by position
33

4-
const scores = [95, 87, 76, 92, 88]
4+
const scores = [95, 92, 88, 87, 76]
55

66
// 🐨 Destructure the first two scores into `highest` and `secondHighest`
77
// 💰 Destructure the first two elements into variables
@@ -21,8 +21,8 @@ const coordinates: [number, number, number] = [10, 20, 30]
2121
// 💰 Return a tuple and destructure the result
2222

2323
// Test - uncomment when ready
24-
// console.log(highest, secondHighest) // 95 87
25-
// console.log(winner, others) // 95 [87, 76, 92, 88]
24+
// console.log(highest, secondHighest) // 95 92
25+
// console.log(winner, others) // 95 [92, 88, 87, 76]
2626
// console.log(x, y, z) // 10 20 30
2727
// console.log(min, max) // 76 95
2828

exercises/04.destructuring/02.solution.array-destructuring/README.mdx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,12 @@
66

77
1. **Position-based extraction**: `const [first, second] = arr`
88
2. **Rest pattern**: `const [head, ...tail] = arr`
9-
3. **Tuple destructuring**: `const [x, y, z] = coordinates`
10-
4. **Function return destructuring**: `const [min, max] = getMinMax(nums)`
9+
3. **Function return destructuring**: `const [min, max] = getMinMax(nums)`
1110

1211
This pattern is foundational for React hooks:
1312

1413
```ts
15-
// useState returns a tuple!
14+
// useState returns an array you can destructure (also called a "Tuple")
1615
const [count, setCount] = useState(0)
1716

1817
// useReducer too

exercises/04.destructuring/02.solution.array-destructuring/index.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ await test('highest and secondHighest should be destructured', () => {
5656
)
5757
assert.strictEqual(
5858
solution.secondHighest,
59-
87,
60-
'🚨 secondHighest should be 87 - destructure second element from scores',
59+
92,
60+
'🚨 secondHighest should be 92 - destructure second element from scores',
6161
)
6262
})
6363

@@ -69,8 +69,8 @@ await test('winner and others should use rest pattern', () => {
6969
)
7070
assert.deepStrictEqual(
7171
solution.others,
72-
[87, 76, 92, 88],
73-
'🚨 others should be [87, 76, 92, 88] - use rest pattern',
72+
[92, 88, 87, 76],
73+
'🚨 others should be [92, 88, 87, 76] - use rest pattern',
7474
)
7575
})
7676

exercises/04.destructuring/02.solution.array-destructuring/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Array Destructuring
22
// Extracting values from arrays by position
33

4-
const scores = [95, 87, 76, 92, 88]
4+
const scores = [95, 92, 88, 87, 76]
55

66
// Destructure first two elements
77
const [highest, secondHighest] = scores
@@ -22,8 +22,8 @@ function getMinMax(nums: Array<number>) {
2222

2323
const [min, max] = getMinMax(scores)
2424

25-
console.log(highest, secondHighest) // 95 87
26-
console.log(winner, others) // 95 [87, 76, 92, 88]
25+
console.log(highest, secondHighest) // 95 92
26+
console.log(winner, others) // 95 [92, 88, 87, 76]
2727
console.log(x, y, z) // 10 20 30
2828
console.log(min, max) // 76 95
2929

exercises/04.destructuring/FINISHED.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ You learned:
1414
🦉 Destructuring is everywhere in modern JavaScript:
1515

1616
```ts
17-
// React hooks return tuples
17+
// React hooks return arrays you can destructure
1818
const [count, setCount] = useState(0)
1919

2020
// Props destructuring
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)