Tell us what’s happening:
Ok so… I understand everything (I think) except I don’t understand why:
const {tomorrow : tempOfTomorrow } = avgTemperatures;
is not
const {tomorrow : tempOfTomorrow } = AVG_TEMPERATURES; ?
Where is avgTemperatures even defined in the first place? If the object tomorrow holds the value of 79, under the constant AVG_TEMPERATURES, and you’re trying to assign that to tempOfTomorrow… where does avgTemperatures come from?
Someone else said: "The function takes a parameter.
Instead of using that parameter, you’ve hardcoded in a reference to the object used to test your code works."
…but I don’t understand this.
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 } = avgTemperatures; // 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; rv:65.0) Gecko/20100101 Firefox/65.0
.
Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/es6/use-destructuring-assignment-to-assign-variables-from-objects/