About Destructuring Assignment to Assign Variables from Objects

About Destructuring Assignment to Assign Variables from Objects


i have a feeling that I don’t understand the full picture of this tutorial, i have no idea what to do.
it’s giving me this :
“destructuring with reassignment was used”

Your code so far

  today: 77,
  tomorrow: 79

function getTempOfTmrw(x) {
  "use strict";
  const  {tomorrow: tempOfTomorrow} = x; 
  return tempOfTomorrow;


Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36.

Link to the challenge:


I think you solved the problem correctly but by changing the name of the argument to ‘x’ you messed up their test. The instructions were to not change code above a certain line which you have done.


Is it just being finicky because you changed the name of the argument - avgTemperatures is the one used in the code, and you’ve changed it to x. It looks correct otherwise, I don’t think you’re misunderstanding anything

Edit: Snap!


Weird thing, but this challenge doesn’t work with the right code.

  today: 77.5,
  tomorrow: 79

function getTempOfTmrw(avgTemperatures) {
  "use strict";
  // change code below this line
  const {tomorrow : tempOfTomorrow, today : a} = AVG_TEMPERATURES; // change this line
  // change code above this line
  return tempOfTomorrow;

console.log(getTempOfTmrw(AVG_TEMPERATURES)); // should be 79

This code doesn’t work. With “today : a” or without - an error occurs. “destructuring with reassignment was used”
I think there is something wrong with this challenge.


Your issue is here:

const {tomorrow : tempOfTomorrow, today : a} = AVG_TEMPERATURES

You are accessing the test object directly, not the object being passed into the function


oh, thank you. I got task a bit wrong.


thank you for the help guys, i think this tutorial was the most difficult one I encountered so far!!