Use Destructuring Assignment to Assign Variables from Objects -01

Use Destructuring Assignment to Assign Variables from Objects -01
0

#1

Tell us what’s happening:
Hi: Can anyone help me find out why this won’t say I have passed. 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 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 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


#2

You destructured an object properly but you destructured the global AVG_TEMPERATURES. You need to work with the argument of the function.

By accessing the global variable your function will only work on objects named AVG_TEMPERATURES that are in the scope of your function. If you work solely on the object passed to the function as a parameter then it will work with any object that has a property tomorrow.