Use De structuring Assignment to Assign Variables from Objects

Tell us what’s happening:

I’m getting the correct answer, but I’m failing the “destructuring with reassignment was used” and cannot figure out why. Any pointers in the right direction would be greatly appreciated!

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 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 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

Bro I just posted the exact same thing, my answer was the same as yours and I cannot figure out what the problem is… I went on to the next challenge and same problem. pls lemme know if you figure it out

1 Like

Someone replied to me, when there is a

“use strict”
you can"t enter in the specific function name inside of your function. Instead, use the value which you pass into the function… ya dig?

lemme know if you have questions but I think you’ll get it.

1 Like

AVG_TEMPERATURES is an argument of getTempofTmrw() function call.
But when working with data inside a function, it’s not the argument to a function call that should be used, but the parameter inserted in the function getTempOfTmrw()

What is it here?

It’s up to you now to find it.

1 Like

Here are more explanations:

Many documentations and tutorials use the words parameters and arguments interchangeably and it’s confusing.

Here is an example that shows you the difference between the two:

function myFunction(parameter) { 
// parameter gets its value from argument variable passed to myFunction() call.

/* inside a function, the variable parameter 
should be used, not argument. */

/* i.e. You should not use argument variable inside the function */

console.log(parameter) /* output: This is an argument when 
it is passed into myFunction call, and parameter 
when used inside the function */
}

...

var argument = "This is an argument when it is passed into myFunction call, and parameter when used inside the function.";
myFunction(argument);
1 Like