I get the temperature right ( 79) and this test fails: “destructuring with reassignment was used”.
I don’t understand this concept. Please help. Thank you.
Your code so far
const AVG_TEMPERATURES = {
today: 77.5,
tomorrow: 79
};
function getTempOfTmrw(avgTemperatures) {
"use strict";
// change code below this line
const tempOfTomorrow = avgTemperatures.tomorrow ; // 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_13_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36.
Okay, you haven’t used destructuring here at all, which is the main point of the exercise. So until you do that, the tests will always fail
Putting that aside, what happens if I run this function like so:
getTempOfTmrw({today: 50, tomorrow: 56})
Which is completely valid. I can clearly see the temperature tomorrow is 56, but your code will return 79. Also what happens if I delete the AVG_TEMPERATURES object (given its just there to check the function works)?
It is a little bit strange, and definitely quite confusing at first sight - hopefully it’s a bit easier to grok when you see it’s just basically the opposite of the object creation.