Hello everyone! My code doesn't executes :S

In this lesson the example codes are :

const user = {
  johnDoe: { 
    age: 34,
    email: 'johnDoe@freeCodeCamp.com'
  }
};

Here’s how to extract the values of object properties and assign them to variables with the same name:

const { johnDoe: { age, email }} = user;

And here’s how you can assign an object properties’ values to variables with different names:

const { johnDoe: { age: userAge, email: userEmail }} = user;

I tried to executes the code but i can’t do it in the inner console of freeCodeCamp.org nor chrome/firefox dev console.

I understand nothing because when i write the code for the lesson it works but otherwise not.

Can somebody tell why please?

FROM LESSON:

Tell us what’s happening:

  **Your code so far**

const LOCAL_FORECAST = {
yesterday: { low: 61, high: 75 },
today: { low: 64, high: 77 },
tomorrow: { low: 68, high: 80 }
};

// Only change code below this line

const lowToday = LOCAL_FORECAST.today.low;
const highToday = LOCAL_FORECAST.today.high;

// Only change code above this line
  **Your browser information:**

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.182 Safari/537.36.

Challenge: Use Destructuring Assignment to Assign Variables from Nested Objects

Link to the challenge:

You aren’t doing this, and this is the point of this particular challenge.

2 Likes

Look at the second example, think about which values are given and which are not → those are newly created.
Then apply the same structure to the code-task.

1 Like

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