Use Destructuring Assignment to Assign Variables from Objects(Newbie)

Tell us what’s happening:
Hello People,
I’ve been trying to complete this task for a while its been a bit challenging. The task is to obtain the average temp for tomorrow form the object AVG_TEMPERATURES using destructing. Based on the examples given and other videos I’ve watched, I felt what I have done so far was sufficient. I’ve been able to return the correct value but still cant complete the challenge.
Any help would be much appreciated.
Your code so far

  today: 77.5,
  tomorrow: 79

function getTempOfTmrw(avgTemperatures) {
  "use strict";
  // change code below this line
  const {today,tomorrow} = AVG_TEMPERATURES; // change this line
  const {tomorrow: tempOfTomorrow} = AVG_TEMPERATURES;
  // 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/71.0.3578.98 Safari/537.36.

The function takes an argument: you aren’t using the argument, you’re using the variable that refers to object used to test the code.

You’ve also got two lines of code when there should be one (the first line is redundant and will cause the tests to fail when you fix the incorrect variable name)

In this case the tests are checking exactly what you are writing.
Anyway, this is duplicate code, you need only to destructure tomorrow. Once. You are doing it twice, once you are not changing the variable name, the other you are.

And also what he said above.

1 Like

Thanks a lot for your reply. Didnt know the variable declared above the function and the argument were different. Thanks a lot

1 Like

Thanks a lot for your response. Just got it working now. Cheers