ES6: Use Destructuring to Assign Variables from Objects

ES6: Use Destructuring to Assign Variables from Objects
0

#1

I searched around for what other people posted about this challenge, but their challenges look different. Did FreeCodeCamp update it recently? Anyhow, here’s what I came up with.

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

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

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

My function returns 79 as it should, but I’m failing the ‘destructuring with reassignment was used’ test. I’m pretty positive that’s what I used, though. Is there a bug in the challenge, or do I have some kind of blind spot?


#2

It appears at a glance that you did the destructuring of the object properly but you destructured both properties when you only needed the one.


#3

Yeah, that was it. Thank you!