Use Destructuring Assignment to Assign Variables from Nested Objects --

Tell us what’s happening:

The answer is correct but I don’t know why It is not passing the test

Your code so far

  today: { min: 72, max: 83 },
  tomorrow: { min: 73.3, max: 84.6 }

function getMaxOfTmrw(forecast) {
  "use strict";
  // change code below this line
  const { max: maxOfTomorrow } = LOCAL_FORECAST.tomorrow; // change this line
  // change code above this line
  return maxOfTomorrow;

console.log(getMaxOfTmrw(LOCAL_FORECAST)); // should be 84.6

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36.

Link to the challenge:

Hey, this is not correct. You have to

  1. Never refer to specific function argument that specific cases are regarding (LOCAL_FORECAST in this challenge.) Instead referring to the forecast parameter will make the function work for any argument you pass to it.

  2. The challenge is asking you to do nested destructuring, think of it as accessing an object within an object, like this.

{tomorrow :{max:maxOfTomorrow}}

So here’s the full line of code:

const {tomorrow :{max:maxOfTomorrow}} = forecast;

1 Like

thank you, it is working fine

Good, are you understanding it?

forecast represents any object. And tomorrow is the property of LOCAL_FORECAST object

1 Like

thanks it help me as well
i din’t understand what it ment