Nested deconstructing challenge not letting me pass event though my output is correct

Tell us what’s happening:
My code is outputting the correct value (84.6) but it says I am not using “nested deconstructing” but It looks like I am. What is wrong with my code?

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 {
  today: {min: minA, max: maxA},
  tomorrow: {min: minB, max: maxB}
 } = LOCAL_FORECAST;
 
  const maxOfTomorrow = maxB; // 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 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.181 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

Hello there!

To use destructuring you must get the value of maxOfTomorrow directly from the const forecast:

// change code below this line
  const { tomorrow: {max: maxOfTomorrow}} = forecast; // change this line
  // change code above this line

This way maxOfTomorrow will be filled with the value of the forecast.tomorrow.max. Also note that I’m using the “forecast” and not the “LOCAL_FORECAST”; this is because getMaxOfTmrw is a function that takes as argument a forecast, and using it makes the function reusable for any forecast that is passed to it. If you use LOCAL_FORECAST, your function only will be used for that specific forecast.

@Raptortilla Your code has been blurred out to avoid spoiling a full working solution for other campers who may not yet want to see a complete solution. In the future, if you post a full passing solution to a challenge and have questions about it, please surround it with [spoiler] and [/spoiler] tags on the line above and below your solution code.

Thank you.

1 Like