ES6 challenge: destructuring assignment

Please tell why is this error happening?

destructuring with reassignment was used

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/74.0.3729.169 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

In your solution you need to find the value of tomorrow of AVG_TEMPERATURES so look at extracting the value of that property. HINT: {tomorrow : tempOfTomorrow} is not correct, you need to look at the AVG_TEMPERATURES part to extract.

Your issue is that you are using the global object, but whenever you have a function parameter you should be using that one in your function

In this case the function parameter is avgTemperatures so you should be descructuring that one and not AVG_TEMPERATURES

That’s the correct way of destructuring an object - how would you do it?

Thanks I got it:slightly_smiling_face: