Code works, solution doesn't! Use Destructuring Assignment to Assign Variables from Objects

Code works, solution doesn't! Use Destructuring Assignment to Assign Variables from Objects
0

#1

Tell us what’s happening:
Hi,

Can someone help on this please? The solution works- it prints out the answer 79 and assigns the destructured “tomorrow” variable to tempOfTomorrow in-line.

The tests say that the error is that destructuring with reassignment was used. I thought that’s what it was asking me to do?

Thanks in advance

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


#2

Hey @jackhaugh,
Here is an answer i gave to someone with similar question as yours:

Hope this helps.


#3

Thanks a lot, Aditya. Good explanation too!