Struggling with - Use Destructuring Assignment to Assign Variables from Objects

I’ve been stuck on this challenge for a day or so, I think I understand the reassignment part, however I looked for the hint and totally do not understand the string prototype thing.

I think thats the step i’m missing?

Your code so far

  today: 77.5,
  tomorrow: 79

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

Link to the challenge:

const tempOfTomorrow = AVG_TEMPERATURES

This above line is unnecessary

const {today , tomorrow} = tempOfTomorrow;

The issue is with this line. When writing this statement, consider the following syntax:
const {value wanted in object : variable to assign it to} = object where it is located

Using that try and reconstruct your statement

1 Like

const { 79 : tempOfTomorrow} = AVG_TEMPERATURES;

so when I try this, my code still doesn’t run

// running tests

getTempOfTmrw(AVG_TEMPERATURES) should be 79

destructuring with reassignment was used

// tests completed

Okay I see that I am supposed to use tomorrow as the value however when I do this my code does return 79, however it is not accepted as deconstruction with reassignment, can you tell me why this is?

[quote=“spreti, post:3, topic:232980”]

and when I use tomorrow as my value,
it does return 79, however it does not consider this destructuring can you give me more insight on this?

const { tomorrow : tempOfTomorrow} = AVG_TEMPERATURES;

it looks like in your code:

const { tomorrow : tempOfTomorrow} = AVG_TEMPERATURES;

you are accessing the object AVG_TEMPERATURES directly. Try instead accessing the object that was passed to you as an argument (avgTemperatures)


That was the trick, THANK YOU for your help!!

1 Like

hah it worked. thank you. I struggled a bit and used AVG_TEMPERATURS instead of the argument you suggested. you spared us a great headache