ES6: Use Destructuring Assignment to Assign Variables from Objects issues

I cannot get past this tutorial.

Below is my solution. It is saying I haven’t used destructuring. I’m not sure what I’m doing incorrectly. I thought I had structured things exactly as was shown in the demonstration and hint.

  today: 77.5,
  tomorrow: 79

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

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

Parameter of function getTempOfTmrw is avgTemperatures, not AVG_TEMPERATURES. Also you don’t need to think about temperature of today, only about temperature of tomorrow

The conditions to pass the assessment are:

  • getTempOfTmrw(AVG_TEMPERATURES) should be 79

  • destructuring with reassignment was used

I still don’t see why this solution doesn’t pass this specific test.

AVG_TEMPERATURES is outside of function’s scope

But AVG_TEMPERATURES is what the test asks for. Isn’t the variable tested by a function able to be anything so long as it follows the data structure expected by the function?

function getTempOfTmrw(n) {

K changed the function to this, and it still processes AVG_TEMPERATURES just fine.

First you are writing a function with parameter avgTemperatures and after you are calling that function already with AVG_TEMPERATURES. Output inside of console is 79. If your parameter is n, inside of function is visible n, but AVG_TEMPERATURES also is not visible

The problem is that you are not using the function parameter. Rather you directly use the variable. To pass the test you need to use the function parameter. If you change the parameter like this function getTempOfTmrw(n), then you, for example, use n within your function. But to pass the test you need to use the parameter they originally provided you with.