Destructuring to Assign Variables from Nested Objects return an object

Tell us what’s happening:

shouldn’t
~console.log(tomorrow.maxOfTomorrow) ~
display maxOfTomorrow since it is a object?

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}}=forecast; // change this //line
  // change code above this line
  console.log(maxOfTomorrow);
  console.log(tomorrow.maxOfTomorrow);
  return maxOfTomorrow;
}

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

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.157 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 need to remove this console.log statement, because tomorrow has no context outside the forecast object. It is causing the tests to fail because the code errors out before the tests can run.

I thought tomorrow was being assigned the object forecast.tomorrow. Sorry, just trying to understand. I knew it was throwing an error, but thought it was an variable of type object.

The only property being assigned to a variable is the max property of the tomorrow property.

Thank you. I think the example was missed stated.

In what way do you think it was incorrect?

It says the variable start is assigned a.start which is an object. If you look at the link to the challenge you will see the example. It’s okay, it just wanted to see if it was an object. I think I have a grasp on it now. Thanks for everything. What you said clicked with me.