Tell us what’s happening:
There is no mistake in my code,Still its showing error. In console its showing ’ 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 : 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 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 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
You have this avgTemperatures
argument in your function but you are not using it anywhere in your function.
Think about where you can use it.
And try solving.
Does that help?
3 Likes
avgTemperatures is an argument and in console we are using it by replacing it with AVG_TEMPERATURES.
console is not showing any error, infact it is showing right value which is 79, it is showing
’ destructuring with reassignment was used’ . It means my code is right.
I think you are not getting my point.
What i am trying to say is that by using AVG_TEMPERATAURES
here:
You are creating your function in manner that it will work only on AVG_TEMPERATURES
object.
Yes you are.
But, what if there was another object like :
const AVG_TEMPERATURES1 = {
today: 75.5,
tomorrow: 80
};
?
You will have to write function for that too.
So, you should use the argument passed in your function instead of actual object name and your function will be applicable for every object.
Hope this helps.
4 Likes
Ohh…this challenges were so basic, I didnt thought of that, thanks dude.
1 Like
I see same problem, you fixed it?
my solve:
const {tomorrow : tempOfTomorrow} =avgTemperatures;
cause in function getTempOfTmrw have argumen is avgTemperatures