-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathes6_12.js
executable file
·58 lines (40 loc) · 1.39 KB
/
es6_12.js
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
//Use Destructuring Assignment to Assign Variables from ObjectsPassed
/*
Destructuring allows you to assign a new variable name when extracting values.
You can do this by putting the new name after a colon when assigning the value.
Using the same object from the last example:
*/
const user = { name: 'John Doe', age: 34 };
//Here's how you can give new variable names in the assignment:
const { name: userName, age: userAge } = user;
/*
You may read it as "get the value of user.name and assign it to a new variable
named userName" and so on. The value of userName would be the string John Doe,
and the value of userAge would be the number 34.
*/
//QUIZ
//=====
/*
Replace the two assignments with an equivalent destructuring assignment.
It should still assign the variables highToday and highTomorrow the
values of today and tomorrow from the HIGH_TEMPERATURES object.
*/
const HIGH_TEMPERATURES = {
yesterday: 75,
today: 77,
tomorrow: 80
};
// Only change code below this line
const highToday = HIGH_TEMPERATURES.today;
const highTomorrow = HIGH_TEMPERATURES.tomorrow;
// Only change code above this line
//ANSWER
//======
const HIGH_TEMPERATURES = {
yesterday: 75,
today: 77,
tomorrow: 80
};
// Only change code below this line
const {today:highToday,tomorrow:highTomorrow} = HIGH_TEMPERATURES;
// Only change code above this line