lowToday should be equal to 64 and highToday should be equal to 77

Original code:

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

You need to replace those two variable assignments with a destructuring assignment.

you mean those two todays?

I mean highToday and lowToday

Replace the two assignments with an equivalent destructuring assignment. It should still assign the variables lowToday and highToday the values of today.low and today.high from the LOCAL_FORECAST object.

so do you mean the local_forcast?

LOCAL_FORECAST is above the comment that says

// Only change code below this line

so no, Iā€™m not telling you to ignore the instructions.

The instructions want you to replace this part:

const lowToday = LOCAL_FORECAST.today.low;
const highToday = LOCAL_FORECAST.today.high;

I did not understand your reply. then what is the part I should delete?

You need to replace the two lines I highlighted with a destructuring assignment.

Iā€™m not sure how to be clearer about which part of the code to change. We arenā€™t going to do it for you.

Can you repeat which two lines you need to replace so I know we at least are on the same page that far?

these two lines need to be replaced?

const lowToday = LOCAL_FORECAST.today.low;
const highToday = LOCAL_FORECAST.today.high;

Yeah. Do you know which part of the instructions show an example of a destructuring assignment?

no I donā€™t see that part.

Hereā€™s how to extract the values of object properties and assign them to variables with the same name:

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

And hereā€™s how you can assign an object propertiesā€™ values to variables with different names:

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

This is what happens if you just blindly copy the hint solution code. It is (was) missing the initial object that the values are pulled from. I updated the solution.

I donā€™t really understand why you would just blindly copy the solution code. The fact that you do not understand where the data is coming from is a big problem. Understanding the destructuring syntax doesnā€™t help much if you do not understand where the destructured data is coming from.

I changed those two lines of code and just passed it. Thank you @JeremyLT !

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