|
1 | 1 | // 1 |
2 | | -> const userInfo = ['John', 'chef', 34]; |
| 2 | +const userInfo = ['John', 'chef', 34]; |
| 3 | + |
3 | 4 | // 2 |
4 | | -> function printUser(name, job, age) { |
5 | | -... console.log(name + ' is working as ' + job + ' and is ' + age + ' years old'); |
6 | | -... } |
| 5 | +function printUser(name, job, age) { |
| 6 | +console.log(name + ' is working as ' + job + ' and is ' + age + ' years old'); |
| 7 | +} |
7 | 8 |
|
8 | 9 | // 3 |
9 | | -> printUser(...userInfo) |
10 | | -John is working as chef and is 34 years old |
| 10 | +printUser(...userInfo) |
11 | 11 |
|
12 | 12 | // 4 |
13 | | -> const detailedInfo = ['male', ...userInfo, 'July 5'] |
14 | | -=> [ 'male', 'John', 'chef', 34, 'July 5' ] |
| 13 | +const detailedInfo = ['male', ...userInfo, 'July 5'] |
| 14 | +console.log(detailedInfo) |
15 | 15 |
|
16 | 16 | // 5 |
17 | | -> let detailedInfoCopy = [ ...detailedInfo ]; |
18 | | -=> undefined |
19 | | -> detailedInfoCopy |
20 | | -=> [ 'male', 'John', 'chef', 34, 'July 5' ] |
| 17 | +let detailedInfoCopy = [ ...detailedInfo ]; |
| 18 | +console.log(detailedInfoCopy) |
21 | 19 |
|
22 | 20 | // 6 |
23 | | -> const userRequest = { name: 'username', type: 'update', data: 'newname'} |
| 21 | +const userRequest = { name: 'username', type: 'update', data: 'newname'} |
24 | 22 |
|
25 | 23 | //7 |
26 | | -> const newObj = { ...userRequest } |
27 | | -=> undefined |
28 | | -> newObj |
29 | | -=> { name: 'username', type: 'update', data: 'newname' } |
| 24 | +const newObj = { ...userRequest } |
| 25 | +console.log(newObj) |
30 | 26 |
|
31 | 27 | //8 |
32 | | -> const detailedRequestObj = { data: new Date(), new: true, ...userRequest} |
33 | | -=> undefined |
34 | | -> detailedRequestObj |
35 | | -=> { data: 'newname', new: true, name: 'username', type: 'update' } |
| 28 | +const detailedRequestObj = { data: new Date(), new: true, ...userRequest} |
| 29 | +console.log(detailedRequestObj) |
36 | 30 |
|
0 commit comments