Destructing Assignment

Tell us what’s happening:

Hello,

My code is using Destructuring Assignment and the function is working but when i Run it: “destructuring with reassignment was used” was not checked.
Is this a bug or I just have the wrong code? (still learning)

Best Regards,
Imen

Your code so far


const AVG_TEMPERATURES = {
  today: 77.5,
  tomorrow: 79
};

function getTempOfTmrw(avgTemperatures) {
  "use strict";
  // change code below this line
  const {today: x, tomorrow: y} = avgTemperatures;
  const tempOfTomorrow = y; // 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 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 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/

Remove today from the destructuring assignment, and replace y with tempOfTomorrow. Delete the next line, isn’t needed anymore, clear the browser cache, then resubmit the test and it should pass.

Your code isn’t technically incorrect (though the point of destructuring is to get the specific values you want, defining today is pointless), the tests are just very picky.

Thank you for your quick reply.
I still have the same problem :confused:

Use the variable name it asks for rather than y - again, the code is actually fine, but the tests are stringent.

Good day. I’m having the same problem as well! Dear ImenBenArbi, were you able to solve this problem?

kind regards

Yes, I have changed “y” by “tempOfTomorrow”.

1 Like

Thank you DanCouper, the problem was resolved

1 Like

Oh dear, I was using AVG_TEMPERATURES instead of avgTemperatures! Thank you for the screenshot. This helped. My issue is resolved.

Thank you very much!