Destructuring nested objects

Tell us what’s happening:

Am I not supposed to use object destructuring? I don’t understand why it isn’t passing the test. My solution ended up being quite similar to the one in the hint.

Your code so far


const LOCAL_FORECAST = {
  today: { min: 72, max: 83 },
  tomorrow: { min: 73.3, max: 84.6 }
};

function getMaxOfTmrw(forecast) {
  "use strict";
  // change code below this line
  const {tomorrow : {max : maxOfTomorrow}} = LOCAL_FORECAST; // 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 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/68.0.3440.75 Chrome/68.0.3440.75 Safari/537.36.

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/es6/use-destructuring-assignment-to-assign-variables-from-nested-objects

You are using nested destructuring.

But, you are extracting max value from only LOCAL_FORECAST object.
Your code wouldn’t work for any other similar object.
Thus, arguement in the function should be used.
Since, function maxOfTmrw has an arguement, called forecast, use that instead of LOCAL_FORECAST.
Hope this helps.

It worked! thanks. I hadn’t taken the argument into account.