Use Destructuring Assignment to Assign Variables from Nested Objects, is this wrong?

Tell us what’s happening:
I feel like my solution is correct and I even checked the hint page to find the exact same answer!
Have I made a mistake?

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 code above this line
  return maxOfTomorrow;
}

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

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

You should not be referencing the global variable LOCAL_FORECAST. Use the argument passed into the getMaxofTmrw instead.

1 Like

D’oh. What an obvious mistake! Thank you :slight_smile: