Use Destructuring Assignment to Assign Variables from Objects-

Tell us what’s happening:
I can’t see what is wrong with my code? It always fails on the second point “destructuring with reassignment was used”.

Can anyone see what I’m doing wrong?

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 (Macintosh; Intel Mac OS X 10_14) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.0 Safari/605.1.15.

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

I figured out what I was doing wrong.

const {tomorrow : tempOfTomorrow} = AVG_TEMPERATURES

should be:

const {tomorrow : tempOfTomorrow} = avgTemperatures

because it is referencing the object passed into the function (avgTemperatures), not the one declared outside (AVG_TEMPERATURES)