Answer not accepted

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

Hello ACPuks.

Think of it like this:
Calling LOCAL_FORECAST returns an object with 3 properties. Each property contains an object with 2 properties.

Now, look at this example:

({a, b, ...rest} = {a: 10, b: 20, c: 30, d: 40});
console.log(a); // 10
console.log(b); // 20
console.log(rest); // {c: 30, d: 40}

If you were to try to destructure an object with 4 properties into an object with more/less properties, how would you divide the 4 properties up?

Now, think about how you would destructure LOCAL_FORECAST (3 properties) into an object with 1 property (today).

It would help, if you read the documentation as well: Mozilla
Hope this helps