ES6 Use Destructuring Assignment to Assign Variables from Objects

Tell us what’s happening:
When i run the code i am getting the correct answer but not passing one of the required fields, it says

destructuring with reassignment was not used

I’m just not sure what it wants me to do here

Your code so far


const AVG_TEMPERATURES = {
  today: 77.5,
  tomorrow: 79
};

function getTempOfTmrw(avgTemperatures) {
  "use strict";
  // change code below this line
  const {tomorrow: tempOfTomorrow} = AVG_TEMPERATURES; // change this line
  // change code above this line
  return tempOfTomorrow;
}

console.log(getTempOfTmrw(AVG_TEMPERATURES)); // should be 79

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.67 Safari/537.36.

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

The function takes a parameter, that’s what you should be using. AVG_TEMPERATURES is used to check your function works, it’s just a test variable.

1 Like