Use Destructuring Assignment to Assign Variables from Objects 2

Use Destructuring Assignment to Assign Variables from Objects 2
0

Tell us what’s happening:
I am solvig this https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/es6/use-destructuring-assignment-to-assign-variables-from-objects

I don’t know why I get this error ‘destructuring with reassignment was used’.

Your code so far


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

function getTempOfTmrw(avgTemperatures) {
  "use strict";
  // change code below this line
  const {today:tempOfToday,tomorrow:tempOfTomorrow} = avgTemperatures; // 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 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 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

You are using destructuring to capture both today and tomorrow properties’ values, but the instructions and tests are expecting you to only capture tomorrow’s value and assign it to tempOfTomorrow.

A big THANK YOU randelldawson :slight_smile: It solved the problem.

Thank you! I also assigned both today and tomorrow.

I have tried reassigning both and just tomorrow’s property but it’s still telling me that I am not using the deconstruction correctly. The console isn’t giving me any errors as either.

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

@thanerdgawd Click on the Ask for Help button which will create a new topic and include your code. This will make it easier to see what you have written and allow us to give you a proper answer.