Tell us what’s happening:
well that is my code and my stupid cant seem to find out the solution for some reason
, if anyone can help me out on this problem i would very much appreciate it
Your code so far
const AVG_TEMPERATURES = {
today: 77.5,
tomorrow: 79
};
function getTempOfTmrw(avgTemperatures) {
"use strict";
// change code below this line
const tempOfTomorrow = {AVERAGE_TEMPERATURES : 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: <code>Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36</code>.
**Link to the challenge:**
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/es6/use-destructuring-assignment-to-assign-variables-from-objects
So the thing is, you’re up to a couple of questionable things.
First, in your getTempOfTmrw(), you’re accessing the global AVERAGE_TEMPERATURES (which, by the way, doesn’t exist – it’s AVG_TEMPERATURES). Don’t access the globals, that’s bad form (and in this case, will fail). Your function is passed that same global as a local variable, avgTemperatures, use that instead.
Second, the destructure syntax can be read like a SQL statement: "actual-name as variable-name from table-name". Though, in this case, it’s "property-name as variable-name from object-name";
So, you might look at something more like this syntax:
const {propertyName : variableName} = objectName;
And read that as
const variableName = objectName.propertyName;
(or, in your head, "SELECT propertyName AS variableName FROM objectName", if you think in SQL)
For this assignment, it is overkill. But when you have multiple properties you wish to access, this is a REALLY useful feature.
1 Like
Great minds think alike… and so do we. 
function getTempOfTmrw(avgTemperatures) {
"use strict";
// change code below this line
const tempOfTomorrow = {AVERAGE_TEMPERATURES : tomorrow}; <-------
// change code above this line
return tempOfTomorrow;
}
The line were you are declaring tempOfTomorrow needs to be changed
from this:
const tempOfTomorrow = {AVERAGE_TEMPERATURES : tomorrow};
to this:
const { tomorrowTemp: tomorrow } = avgTemperatures;
In fact, you can even write it like this:
const { tomorrow } = avgTemperatures;
I believe you’ve got the destructure exactly backwards. The object property is listed before the colon, the variable name to which you’re assigning after.
You’re correct @snowmonkey, apologies for the oversight on my part
const { tomorrow : tomorrowTemp: } = avgTemperatures;
You realize, of course, that I was trying to be sneaky and NOT give the answer…