ES6 - Use Destructuring Assignment to Assign Variables from Objects

The explanation is unclear and the hint is not helpful.

Any help gratefully appreciated.

Your code so far

const HIGH_TEMPERATURES = {
  yesterday: 75,
  today: 77,
  tomorrow: 80
};

// Only change code below this line
  
const {name: HIGH_TEMPERATURES.today} = highToday;
const |{name: HIGH_TEMPERATURES.tomorrow} = highTomorrow; 

// Only change code above this line

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:106.0) Gecko/20100101 Firefox/106.0

Challenge: ES6 - Use Destructuring Assignment to Assign Variables from Objects

Link to the challenge:

You should probably fix this syntax error:

SyntaxError: unknown: Unexpected token, expected "," (9:30)

   7 | // Only change code below this line
   8 |   
>  9 | const {name: HIGH_TEMPERATURES.today} = highToday;
     |                               ^
  10 | const |{name: HIGH_TEMPERATURES.tomorrow} = highTomorrow; 
  11 |
  12 | // Only change code above this line

I don’t see dot notation used in the example:

const { name: userName, age: userAge } = user;

Also, the variable being destructured goes on the right side of the = sign.

As per the example, the syntax should be const {: }.
Automatically, it will extract the value of that property from the object into the variable name you give.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.