Question: Use destructuring to obtain the average temperature for tomorrow from the input object AVG_TEMPERATURES , and assign value with key tomorrow to tempOfTomorrow in line.
Error : “destructuring with reassignment was used remains” remains unticked.
function getTempOfTmrw(avgTemperatures) {
“use strict”;
// change code below this line
const tempOfTomorrow = undefined; // change this line
// change code above this line
return tempOfTomorrow;
}
console.log(getTempOfTmrw(AVG_TEMPERATURES)); // should be 79
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 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36.
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;
}
console.log(getTempOfTmrw(AVG_TEMPERATURES)); // should be 79
It looks like the test wants you to destruct only the tempOfTomorrow. No need to get the tempOfToday too. It shouldn’t matter, but sometimes FCC tests are a little too rigid.
function getTempOfTmrw(AVG_TEMPERATURES) {
“use strict”;
// change code below this line
const {today, tomorrow:tempOfTomorrow} = AVG_TEMPERATURES;
// change this line
// change code above this line
return tempOfTomorrow;
}
console.log(getTempOfTmrw(AVG_TEMPERATURES)); // should be 79
function getTempOfTmrw(AVG_TEMPERATURES) {
“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
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
I see. The parameter and the variable name should have been identical. My parameter was avgTemperatures but the constant it referred to was AVG_TEMPERATURES.
It now works. Thank you for your help and patience, Ghukahr.