Question Regarding Destructuring Assignment

When I used Destructuring Assignment to Assign Variables from Nested Objects to replace low with lowToday and high with highToday in today’s object, the code will run with no issues, but when I log LOCAL_FORECAST.today it still displays low and high rather lowToday and highToday. Why is that? And when I tried to log LOCAL_FORECAST.today.lowToday, the output is undefined. Could someone explain this please?

  **Your code so far**

const LOCAL_FORECAST = {
yesterday: { low: 61, high: 75 },
today: { low: 64, high: 77 },
tomorrow: { low: 68, high: 80 }
};

// Only change code below this line

const {today: {low: lowToday, high: highToday}} = LOCAL_FORECAST
console.log(LOCAL_FORECAST.today)

  **Your browser information:**

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.82 Safari/537.36 Edg/93.0.961.52

Challenge: Use Destructuring Assignment to Assign Variables from Nested Objects

Link to the challenge:

Using destructuring does not mutate the original object (in this case LOCAL_FORECAST), it only declares new variables (lowToday and highToday).

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.