-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathappAnswers.js
More file actions
78 lines (60 loc) · 1.89 KB
/
Copy pathappAnswers.js
File metadata and controls
78 lines (60 loc) · 1.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
// let facts = { numPlanets: 8, yearNeptuneDiscovered: 1846 };
// let { numPlanets, yearNeptuneDiscovered } = facts;
// console.log(numPlanets); // 8
// console.log(yearNeptuneDiscovered); // 1846
// let planetFacts = {
// numPlanets: 8,
// yearNeptuneDiscovered: 1846,
// yearMarsDiscovered: 1659,
// };
// let { numPlanets, ...discoveryYears } = planetFacts;
// console.log(discoveryYears);
// // { yearNeptuneDiscovered: 1846,
// // yearMarsDiscovered: 1659}
// function getUserData({ firstName, favoriteColor = "green" }) {
// return `Your name is ${firstName} and you like ${favoriteColor}`;
// }
// getUserData({ firstName: "Alejandro", favoriteColor: "purple" }); // ?
// getUserData({ firstName: "Melissa" }); // ?
// getUserData({}); // Your name is undefined and you like green}
// let [first, second, third] = ["Maya", "Marisa", "Chi"];
// console.log(first); // Maya
// console.log(second); // Marise
// console.log(third); // Chi
// let [raindrops, whiskers, ...aFewOfMyFavoriteThings] = [
// "Raindrops on roses",
// "whiskers on kittens",
// "Bright copper kettles",
// "warm woolen mittens",
// "Brown paper packages tied up with strings",
// ];
// console.log(raindrops); // Raindrops on rose
// console.log(whiskers); // whicksers on kittens
// console.log(aFewOfMyFavoriteThings); // [bright copper kettles, warm woolen mittens, brown paper packages tied uup with strings]
// let numbers = [10, 20, 30];
// [numbers[1], numbers[2]] = [numbers[2], numbers[1]];
// console.log(numbers); // 10,30,20
// Object Destructuring
const obj = { numbers: { a: 1, b: 2 } };
({
numbers: { a, b },
} = obj);
///Array Swap
let one = 1;
let two = 2;
[one, two] = [two, one];
let raceResults = ([first, second, third, ...rest]) => {
return {
first,
second,
third,
rest,
};
};
//or
// let raceResults = ([first, second, third, ...rest]) => ({
// first,
// second,
// third,
// rest,
// };)