Destructuring Assignment to Assign Variables from Objects!

Tell us what’s happening:
Hello, please help I am stuck here ! Can’t complete the ‘destructuring with reassignment was used’ clause.

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 haven’t used that parameter, you’ve used the object that’s there to test the function: you’ve hardvoded some values into the finction

1 Like

This one comes up often. A suggestion, if I may, and this goes for all sorts of things: use the search feature in the forums!

See that handy magnifying lens in the header of this page? Search for “Destructuring Assignment to Assign Variables” and a list of search results will appear. One of which is this post, in which I discuss this exact situation.

1 Like

Thank you very much
Got it now

1 Like