ES6: Use Destructuring Assignment to Assign Variables from Objects ELI5 plz

Hello there I am on this challenge now and it asks me to assign the value of tommorow the object AVG_TEMPERATURES, to tempOfTomorrow. Now I succeeded in doing that but I still don’t pass the challenge because ‘destructuring with reassignment was used’ won’t check. But thats what I did right by getting the value from the object.

Current code:

const AVG_TEMPERATURES = {
today: 77.5,
tomorrow: 79
};

function getTempOfTmrw(avgTemperatures) {
“use strict”;
// change code below this line
const {tomorrow: tempOfTomorrow,} = avgTemperatures;
// change code above this line
return tempOfTomorrow;
}

console.log(getTempOfTmrw(AVG_TEMPERATURES)); // should be 79

As far as I can see, the tests are just being strict, your code looks fine, but there’s a comma after tempOfTomorrow that the test is choking on - there shouldn’t be a problem with it in reality, but the test that is failing works by checking the actual thing you’ve typed, not by running the code.

1 Like