Use Destructuring Assignment to Assign Variables from Objects 3

Use Destructuring Assignment to Assign Variables from Objects 3
0

#1

Tell us what’s happening:

Your code so far


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

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

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

Hi, I cannot understand wats wrong, any ideas?

User Agent is: Mozilla/5.0 (Windows NT 6.1; rv:63.0) Gecko/20100101 Firefox/63.0.

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/es6/use-destructuring-assignment-to-assign-variables-from-objects/


#2

First of all you shouldn’t be referring to AVG_TEMPERATURES inside the function - it is passed in as avgTemperatures so that is how you are supposed to be using that value inside the function. Secondly, this line needs work:

const {AVG_TEMPERATURES:tomorrow}=tempOfTomorrow;

The order is wrong. If you have an object that is:

const obj = { value: 42 };

You could get it out with:

const { value } = obj;

But we want to also rename it at the same time, so we need something like:

const { value: newValueName } = obj;

Is that clear? Let us know if that is not enough of a hint?


#3

yes, but I had to check again in the forum. I will have to check more on JS building blocks. I tryed a lot of things but didn’t work. Finally I managed to pass.


#4

Hey, you want to pair program or work on some practice project?


#5

Sorry, I’m busy with a new job.


#6

No worries, thanks for reply anyway.