Use Destructuring Assignment

Tell us what’s happening:
Hi,

can someone help me with this one, I don’t understand why the test say “destructuring with reassignment was used”

Thanks

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/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/

The function takes a parameter, you aren’t using it. Instead, you’ve used the variable that is there to check your code works

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

function getTempOfTmrw(avgTemperatures) {
“use strict”;
// change code below this line
const {tomorrow: tempOfTomorrow} = avgTemperatures; // change this line
// change code above this line
return tempOfTomorrow;
}

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

Thanks guys, suddenly it seems simple

1 Like

how you did it? i,m still stuck

if you need help you can use the ask for help button in the challenge, so the code is already included, and you just need to write something

a common error in this challenge is not using the function parameter, but the global object

thank you …the task is finished