Problem with "Use Destructuring Assignment to Assign Variables from Objects"

Tell us what’s happening:
I get a check mark for having the correct return value, but am not getting a check mark on the “destructuring with reassignment was used” task. I also see this is in the console:

// running tests
destructuring with reassignment was used
// tests completed

I’ve looked at several other forum posts with users encountering the same problem, and saw that my solution was what others were suggesting as “the” solution. The “Get A Hint” link is not helpful; it seems to be referring to an older version of this challenge.

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 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.102 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/

The function takes a parameter, you are supposed to use that parameter. Instead, you’ve used the object used to test that your code works. It’s not that the get a hint is wrong or out of date or wrong, it’s that you’ve hard coded one specific answer into your function.

1 Like

face palm

Thank you!

1 Like