Destructuring Assignment and assigning variables from objects

Destructuring Assignment and assigning variables from objects
0

#1

Hello, I don’t understand why I can’t pass the test in this challenge. It says I’m not using destructuring with reassignment but I am. Or am I…?

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

Thank you for help.


#2

There’s a difference between an argument and a parameter.


#3

The function takes an argument avgTemperatures. What happens if you do:

getTempOfTmrw({today: 60, tomorrow: 62})

That should work fine, but in your code it won’t


#4

Thank you, I have managed to solve it. Like you said, the fact that parameter and argument are very similar in this challenge makes it very confusing for beginners like me.


#5

Great that you’ve done it and got that beautiful window with a green sign of success appearing on your screen.

Good Luck & Happy Coding.