ES6 - Use Destructuring Assignment to Assign Variables from Nested Objects

Tell us what’s happening:
Describe your issue in detail here.

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 lowToday = LOCAL_FORECAST.today.low;
const highToday = LOCAL_FORECAST.today.high;

// Only change code above this line

Your browser information:

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

Challenge: ES6 - Use Destructuring Assignment to Assign Variables from Nested Objects

Link to the challenge:

It doesn’t look like you made any changes to the starter code. Was this post a mistake, or did you have a question about this lesson?

I think if you remove the other properties from the object and format it the same way as in the example it might help.

Example code:

const user = {
  johnDoe: { 
    age: 34,
    email: 'johnDoe@freeCodeCamp.com'
  }
};

const { johnDoe: { age: userAge, email: userEmail }} = user;

Altered editor code:

const LOCAL_FORECAST = {
  today: {
    low: 64,
    high: 77
  }
};

const = ???

The two should now be similar enough for you to better spot the pattern used.

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