Use Destructuring Assignment to Assign Variables from Objects - reassignment was used

Tell us what’s happening:
It is showing me the error “destructuring with reassignment was used”. What am I doing wrong? Still learning:hugs:

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 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.121 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

AVG_TEMPERATURES is the global object. See if you can figure out how that global object is passed into the getTempOfTmrw function.

3 Likes

The instructions are wrong: you actually need to destructure avgTemperatures, not AVG_TEMPERATURES. This should be fixed by the time the next release rolls out.

2 Likes

Thx now i understand that the global var AVG_TEMPERATURES is getting passed into the function as the var avgTemperatures.

2 Likes

The tests are being fixed and will be hopefully rolled out in the next production release.