Ask for Use Destructuring Assignment to Assign Variables from Objects

why it doesn’t work

  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 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.121 YaBrowser/ Yowser/2.5 Safari/537.36.

Link to the challenge:

You need to destructure the argument to the function, avgTemperatures and NOT the global variable AVG_TEMPERATURES

The instructions are a little confusing


@Alex121618, this is quite tricky as I had to look closely to discover that you are not using the argument passed to the function avgTemperatures instead you tried to access the global variable AVG_TEMPERATURES directly which is not good hence won’t work as expected. However, I feel the error message destructuring with reassignment was used was not descriptive enough as I couldn’t figure out what that actually means until I read @gebulmer’s post above :point_up_2: as a fix, change AVG_TEMPERATURES in the function body to avgTemperatures. This should solve it.

thanks for your support

1 Like