Use Destructuring Assignment to Assign Variables from Objects Question

Tell us what’s happening:

Any idea why this code won’t work? The test result keeps saying “destructuring with reassignment was used” but i thought that’s what i’m supposed to do!

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

Inside your function, you’re using the example object used to test your code (AVG_TEMPERATURES) rather than the argument passed to the function.

Ohh yes, that makes sense. Thanks!

1 Like

Yes, the wording in the instructions tends to trip people up on this one unfortunately!