Use Destructuring Assignment to Assign Variable 1 from Objects

Tell us what’s happening:
My code not passing

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) 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

Think about another variable within the scope of the getTempOfTmrw function which represents the same object as AVG_TEMPERATURES.

1 Like

It’s almost correct, you’re just referring to the wrong variable. You are getting the temperatures as an argument in the function, and that is the constant.

1 Like

Thank you. I was actually referring to the wrong variable.