Skip to content

Commit 7d3cbd8

Browse files
committed
Apply formatting fixes
1 parent f8109e3 commit 7d3cbd8

File tree

6 files changed

+79
-82
lines changed

6 files changed

+79
-82
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@
3232

3333
## Prerequisites
3434

35-
- [Programming Foundations](https://github.com/epicweb-dev/programming-foundations) workshop (or equivalent knowledge)
35+
- [Programming Foundations](https://github.com/epicweb-dev/programming-foundations)
36+
workshop (or equivalent knowledge)
3637
- Understanding of primitive types, variables, and functions in TypeScript
3738

3839
## Pre-workshop Resources

exercises/02.arrays/02.solution.array-types/index.test.ts

Lines changed: 23 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -28,32 +28,29 @@ await testStep(
2828
},
2929
)
3030

31-
await testStep(
32-
'Adding to arrays with spread creates a new array',
33-
async () => {
34-
const products: { name: string; price: number; inStock: boolean }[] = [
35-
{ name: 'Laptop', price: 999.99, inStock: true },
36-
{ name: 'Mouse', price: 29.99, inStock: true },
37-
{ name: 'Keyboard', price: 79.99, inStock: false },
38-
]
39-
const allProducts = [
40-
...products,
41-
{ name: 'Monitor', price: 299.99, inStock: true },
42-
]
43-
expect(
44-
products.length,
45-
'🚨 Original products array should still have 3 items - spread creates a new array without modifying the original',
46-
).toBe(3)
47-
expect(
48-
allProducts.length,
49-
'🚨 allProducts.length should be 4 - the new array contains the original items plus the new one',
50-
).toBe(4)
51-
expect(
52-
allProducts[3].name,
53-
'🚨 allProducts[3].name should be "Monitor" - the new item is at the end of the new array',
54-
).toBe('Monitor')
55-
},
56-
)
31+
await testStep('Adding to arrays with spread creates a new array', async () => {
32+
const products: { name: string; price: number; inStock: boolean }[] = [
33+
{ name: 'Laptop', price: 999.99, inStock: true },
34+
{ name: 'Mouse', price: 29.99, inStock: true },
35+
{ name: 'Keyboard', price: 79.99, inStock: false },
36+
]
37+
const allProducts = [
38+
...products,
39+
{ name: 'Monitor', price: 299.99, inStock: true },
40+
]
41+
expect(
42+
products.length,
43+
'🚨 Original products array should still have 3 items - spread creates a new array without modifying the original',
44+
).toBe(3)
45+
expect(
46+
allProducts.length,
47+
'🚨 allProducts.length should be 4 - the new array contains the original items plus the new one',
48+
).toBe(4)
49+
expect(
50+
allProducts[3].name,
51+
'🚨 allProducts[3].name should be "Monitor" - the new item is at the end of the new array',
52+
).toBe('Monitor')
53+
})
5754

5855
await testStep('Total inventory value calculation with reduce', async () => {
5956
const products: { name: string; price: number; inStock: boolean }[] = [

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

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,14 @@ await testStep('coordinates should be destructured into x, y, z', async () => {
4040
expect(z, '🚨 z should be 30 - destructure from coordinates').toBe(30)
4141
})
4242

43-
await testStep('getMinMax should return tuple and be destructured', async () => {
44-
expect(min, '🚨 min should be 76 - destructure getMinMax result').toBe(76)
45-
expect(max, '🚨 max should be 95 - destructure getMinMax result').toBe(95)
43+
await testStep(
44+
'getMinMax should return tuple and be destructured',
45+
async () => {
46+
expect(min, '🚨 min should be 76 - destructure getMinMax result').toBe(76)
47+
expect(max, '🚨 max should be 95 - destructure getMinMax result').toBe(95)
4648

47-
const [testMin, testMax] = getMinMax([5, 2, 8, 1, 9])
48-
expect(testMin, '🚨 getMinMax([5,2,8,1,9]) should return min 1').toBe(1)
49-
expect(testMax, '🚨 getMinMax([5,2,8,1,9]) should return max 9').toBe(9)
50-
})
49+
const [testMin, testMax] = getMinMax([5, 2, 8, 1, 9])
50+
expect(testMin, '🚨 getMinMax([5,2,8,1,9]) should return min 1').toBe(1)
51+
expect(testMax, '🚨 getMinMax([5,2,8,1,9]) should return max 9').toBe(9)
52+
},
53+
)

exercises/07.spread-rest/01.solution.object-spread/index.test.ts

Lines changed: 30 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -15,31 +15,37 @@ await testStep('original user should be unchanged', async () => {
1515
1616
})
1717

18-
await testStep('finalConfig should merge with user overriding defaults', async () => {
19-
expect(
20-
finalConfig.apiUrl,
21-
'🚨 finalConfig.apiUrl should come from defaults',
22-
).toBe('https://api.example.com')
23-
expect(
24-
finalConfig.timeout,
25-
'🚨 finalConfig.timeout should be 10000 from userConfig (user overrides defaults)',
26-
).toBe(10000)
27-
expect(
28-
finalConfig.retries,
29-
'🚨 finalConfig.retries should come from defaults',
30-
).toBe(3)
31-
})
18+
await testStep(
19+
'finalConfig should merge with user overriding defaults',
20+
async () => {
21+
expect(
22+
finalConfig.apiUrl,
23+
'🚨 finalConfig.apiUrl should come from defaults',
24+
).toBe('https://api.example.com')
25+
expect(
26+
finalConfig.timeout,
27+
'🚨 finalConfig.timeout should be 10000 from userConfig (user overrides defaults)',
28+
).toBe(10000)
29+
expect(
30+
finalConfig.retries,
31+
'🚨 finalConfig.retries should come from defaults',
32+
).toBe(3)
33+
},
34+
)
3235

33-
await testStep('userWithDarkMode should have updated nested settings', async () => {
34-
expect(
35-
userWithDarkMode.settings.theme,
36-
'🚨 userWithDarkMode.settings.theme should be "dark"',
37-
).toBe('dark')
38-
expect(
39-
userWithDarkMode.settings.notifications,
40-
'🚨 notifications should still be true (unchanged)',
41-
).toBe(true)
42-
})
36+
await testStep(
37+
'userWithDarkMode should have updated nested settings',
38+
async () => {
39+
expect(
40+
userWithDarkMode.settings.theme,
41+
'🚨 userWithDarkMode.settings.theme should be "dark"',
42+
).toBe('dark')
43+
expect(
44+
userWithDarkMode.settings.notifications,
45+
'🚨 notifications should still be true (unchanged)',
46+
).toBe(true)
47+
},
48+
)
4349

4450
await testStep('original user settings should be unchanged', async () => {
4551
expect(

exercises/07.spread-rest/02.solution.rest-parameters/index.test.ts

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,12 @@ import { testStep, expect } from '@epic-web/workshop-utils/test'
22
import { multiply, createArray, mergeArrays } from './index.ts'
33

44
await testStep('multiply should use rest parameters', async () => {
5-
expect(
6-
multiply(2, 3, 4),
7-
'🚨 multiply(2, 3, 4) should return 24',
8-
).toBe(24)
9-
expect(
10-
multiply(5),
11-
'🚨 multiply(5) should return 5',
12-
).toBe(5)
13-
expect(
14-
multiply(),
15-
'🚨 multiply() with no args should return 1',
16-
).toBe(1)
17-
expect(
18-
multiply(2, 2, 2, 2),
19-
'🚨 multiply(2, 2, 2, 2) should return 16',
20-
).toBe(16)
5+
expect(multiply(2, 3, 4), '🚨 multiply(2, 3, 4) should return 24').toBe(24)
6+
expect(multiply(5), '🚨 multiply(5) should return 5').toBe(5)
7+
expect(multiply(), '🚨 multiply() with no args should return 1').toBe(1)
8+
expect(multiply(2, 2, 2, 2), '🚨 multiply(2, 2, 2, 2) should return 16').toBe(
9+
16,
10+
)
2111
})
2212

2313
await testStep('createArray should collect items via rest', async () => {

exercises/07.spread-rest/FINISHED.mdx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ You learned:
1111

1212
🦉 The key distinction:
1313

14-
| Context | Name | Effect |
15-
| --------------------- | ------ | ---------------------------- |
16-
| `[...arr]` | Spread | Expands into elements |
17-
| `{ ...obj }` | Spread | Expands into properties |
18-
| `fn(...arr)` | Spread | Expands as function args |
19-
| `function fn(...x)` | Rest | Collects args into array |
20-
| `const [a, ...rest]` | Rest | Collects remaining elements |
21-
| `const { a, ...rest}` | Rest | Collects remaining props |
14+
| Context | Name | Effect |
15+
| --------------------- | ------ | --------------------------- |
16+
| `[...arr]` | Spread | Expands into elements |
17+
| `{ ...obj }` | Spread | Expands into properties |
18+
| `fn(...arr)` | Spread | Expands as function args |
19+
| `function fn(...x)` | Rest | Collects args into array |
20+
| `const [a, ...rest]` | Rest | Collects remaining elements |
21+
| `const { a, ...rest}` | Rest | Collects remaining props |
2222

2323
These patterns are foundational for:
2424

0 commit comments

Comments
 (0)