Tell us what’s happening:
Can someone clarify why destructuring in this way is not accepted as a solution, I thought destructuring is intended to be used this way to reuse code?
Official solution is
const { today: { low: lowToday, high: highToday } } = LOCAL_FORECAST;
Your code so far
const LOCAL_FORECAST = {
yesterday: { low: 61, high: 75 },
today: { low: 64, high: 77 },
tomorrow: { low: 68, high: 80 }
};
// change code below this line
const {high:highToday,low:lowToday}= LOCAL_FORECAST.today;
// change code above this line
console.log(lowToday); // should be 64
console.log(highToday); // should be 77
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.106 Safari/537.36
.
Challenge: Use Destructuring Assignment to Assign Variables from Nested Objects
Link to the challenge:
https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/es6/use-destructuring-assignment-to-assign-variables-from-nested-objects