Use Destructuring Assignment to Assign Variables from Objects - explaining const piece

  today: 77.5,
  tomorrow: 79

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

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

Hello, I have my code block encased above and I do meet all criteria, but I am wondering why I actually need the =avgTempertures variable to be referenced in this problem. I understand that I’m retrieving the value 79 from the const AVG_TEMPERATURES and that the value is given from the return temperatureOfTomorrow line.

So my question is why do I need to equal the value to avgTemperatures if I have already taken the value and returned it where I need.

The lesson:

It’s needed so that the code knows to look into the object passed in as the avgTemperatures paramter for the tomorrow property. Without the reference to avgTempeartures, how would the code know where to get the tomorrow property from?