2018-10-12 15:37:13 -04:00
|
|
|
---
|
|
|
|
title: Use Destructuring Assignment to Assign Variables from Objects
|
|
|
|
---
|
|
|
|
|
2019-07-24 00:59:27 -07:00
|
|
|
# Use Destructuring Assignment to Assign Variables from Objects
|
2018-10-12 15:37:13 -04:00
|
|
|
|
2019-07-30 00:25:58 +05:30
|
|
|
---
|
|
|
|
## Solutions
|
|
|
|
|
|
|
|
<details><summary>Solution 1 (Click to Show/Hide)</summary>
|
|
|
|
|
|
|
|
```javascript
|
|
|
|
const HIGH_TEMPERATURES = {
|
|
|
|
yesterday: 75,
|
|
|
|
today: 77,
|
|
|
|
tomorrow: 80
|
|
|
|
};
|
|
|
|
|
|
|
|
// change code below this line
|
|
|
|
|
|
|
|
const { today: highToday, tomorrow: highTomorrow } = HIGH_TEMPERATURES;
|
|
|
|
|
|
|
|
// change code above this line
|
2018-10-12 15:37:13 -04:00
|
|
|
|
2019-07-30 00:25:58 +05:30
|
|
|
console.log(highToday); // should be 77
|
|
|
|
console.log(highTomorrow); // should be 80
|
|
|
|
```
|
2018-10-12 15:37:13 -04:00
|
|
|
|
2019-07-30 00:25:58 +05:30
|
|
|
</details>
|