N: Use Destructuring Assignment to Assign Variables from Objects

Tell us what’s happening:

Hello,
I have been stuck for some time now at the “Use Destructuring Assignment to Assign Variables from Objects” Challenge.
The task is this : Use destructuring to obtain the average temperature for tomorrow from the input object AVG_TEMPERATURES , and assign value with key tomorrow to tempOfTomorrow in line.

After i try to run my code, the console just reads : destructuring with reassignment was used.

I have looked at the hint section, and it tells me about string objects in js, which is odd, because i do not have string objects. Then i looked on the forum here, and apparently this challenge used to be different some time ago, and it indeed was with string objects.

Any advice on what i may be doing wrong ? ^^

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

You actually need to destructure avgTemperatures and not AVG_TEMPERATURES. The instructions are wrong, that’s all.

1 Like

Thank you very much. It worked ! :smiley: