Use Destructuring Assignment to Assign Variables from Nested Objects_2

Use Destructuring Assignment to Assign Variables from Nested Objects_2
0

#1

Tell us what’s happening:
I’m not passing the test even though I’m getting the correct answer. It seems to me that nested destructuring was used in my code. Was it not used?

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: tomorrowMax}} = forecast;
  const maxOfTomorrow = tomorrowMax; // change this line
  // change code above this line
  return maxOfTomorrow;
}

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

ERROR MESSAGE

// running tests
nested destructuring was used // which I think means it wasn't used.
// tests completed

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 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/


#2

You technically did, the challenge is expecting you to not directly assign maxOfTomorrow a value. The only const line should be the one above. Why not just replace tomorrowMax with maxOfTomorrow in the first const. There is no need for an extra const here.


#3

Thanks. It worked!

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