In this article, we'll look at fundamental JavaScript object syntax, and revisit some JavaScript features that we've already seen earlier in the course, reiterating the fact that many of the features you've already dealt with are objects.
In the above mentioned link,
const myDataName = 'height';
const myDataValue = '1.75m';
person[myDataName] = myDataValue;
Where should I add this code, it is giving me an error since inside the object we cannot assign the value.
In the console also,I m getting error.
mikoMK
(Michael Koch)
March 16, 2022, 2:08pm
2
Hi @vaishnavi_A.N
This goes after the person object. You have something like this:
const person = {
...
};
const myDataName = 'height';
const myDataValue = '1.75m';
person[myDataName] = myDataValue;
We define some properties when creating the person
object in the first part. Then we add another property height
with the second part.
Please tell me if you need more help.
Happy coding,
Michael
2 Likes
Yeah its clear now, I was confused with the line:
To test this, try adding the following lines into your code, just below the closing curly brace of the person
object:
Thank u @mikoMK
1 Like