Tell us what’s happening:
I thought I got the solution correct, but it won’t pass tests. I can’t pass “destructuring with reassignment was used.” But the console states it was.
Your code so far
const AVG_TEMPERATURES = {
today: 77.5,
tomorrow: 79
};
function getTempOfTmrw(avgTemperatures) {
"use strict";
// change code below this line
const { today: tempOfToday, 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_2) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.0.2 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 it out. I was using the objects actual name AVG_TEMPERATURES and not the passed value, avgTemperatures. Simple mistake. 
2 Likes
I’m working on the same exercise and did the same as you. But when I replaced AVG_TEMPERATURES with avgTemperatures it still didnt work?
function getTempOfTmrw(avgTemperatures) {
"use strict";
// change code below this line
const { today: tempOfToday, tomorrow:tempOfTomorrow } = avgTemperatures; // change this line
// change code above this line
return tempOfTomorrow;
}
That’s weird. I just tried the exercise again and I got the same result as you. When I removed today: tempOfToday it worked this time around.
It’s testing that you pull a single property out of the object. The code isn’t technically wrong at all, but it’s not what the challenge is asking for, and the tests check what you’ve written, not just the output of the function.
1 Like
I made the exact same mistake this morning!