Hello, basically i’m blocked at this challenge (title) i written this code but isn’t working need help.
const AVG_TEMPERATURES = {
today: 77.5,
tomorrow: 79
};
function getTempOfTmrw(avgTemperatures) {
"use strict";
// change code below this line
const { tomorrow: a } = avgTemperatures;
const tempOfTomorrow = a; // 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
Your example is very good, but it is confusing to new learners who do not know yet that in ES6: tomorrow inside an obj literal: {tomorrow} is equal to {tomorrow: tomorrow}
And, therefore, returning tomorrow will also do the work.
However, this challenge will not accept that answer, it strictly wants tempOfTomorrow returned.
Just came across this problem and… wow, I definitely think the problem should be reworded.
“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.”
A much better description in my opinion would be, “In function getTempOfTmrw, use destructuring to set tempOfTomorrow to the value of avgTemperatures’ property tomorrow. Then, return tempOfTomorrow .”
I don’t know how ‘liked’ that description would be, but it’s just my 2c, since I interpreted the vanilla description in tens of ways before giving up and coming here. This is the only problem that I’ve encountered with wording that truly threw me off out of everything so far.