Tell us what’s happening:
I need help with an es6 challenge:
so what’s going on is I wrote the code below in the function and the console kept returning the error: “destructuring with reassignment was used”
Your code so far
const AVG_TEMPERATURES = {
today: 77.5,
tomorrow: 79
};
function getTempOfTmrw(avgTemperatures) {
"use strict";
// change code below this line
const {tomorrow : newT} = avgTemperatures; // change this line
// change code above this line
return newT;
}
console.log(getTempOfTmrw(AVG_TEMPERATURES)); // should be 79
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.157 Safari/537.36
.
Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/es6/use-destructuring-assignment-to-assign-variables-from-objects
Read the instructions carefully
[…] assign value with key tomorrow
to tempOfTomorrow
in line.
okay, I did, but I still don’t know what you mean.
You didn’t do the part of the instructions that I referenced.
You shouldn’t change code below that line, it says to change code above it
I redid the code, but the console kept returning that tempOfTomorrow wasn’t defined.
here is the code and by the ways, thanks for telling me about the above and below line code @ilenia.
const AVG_TEMPERATURES = {
today: 77.5,
tomorrow: 79
};
function getTempOfTmrw(avgTemperatures) {
"use strict";
// change code below this line
const {AVG_TEMPERATURES} = tempOfTomorrow; // change this line
// change code above this line
return tempOfTomorrow;
}
console.log(getTempOfTmrw(AVG_TEMPERATURES)); // should be 79
@ConnerOw1115 See the following for the proper syntax:
const { objectProperty: newVariableName } = objectToBeDestructured;
thanks @camperextraordinaire for your help! I passed the challenge!