0

How can I display some properties of this variable?

I am new to Javascript and this is why I got stuck. I want to display some properties of the variable name through id

22nd Mar 2021, 12:16 PM
DN Josh
DN Josh - avatar
4 Respuestas
0
//Here is my code. var person = { firstName: "Jane", age: 20, sex: "Female", }; // I used this to display some properties document.getElementById("demo).innerHTML = person.name + " is" + person.age + "years old",
22nd Mar 2021, 12:20 PM
DN Josh
DN Josh - avatar
0
you need at least to close the "demo" string (missing closing quote)... you must have an element with id="demo" to be able to select it, and the code need to have been parsed before trying to access it with js ^^
22nd Mar 2021, 12:26 PM
visph
visph - avatar
0
visph i have that in the html Something like this:👇 <h1 id="demo"> </h1>
22nd Mar 2021, 12:49 PM
DN Josh
DN Josh - avatar
0
ok. you must close thr "demo" string, and be sure that your code run when your <h1 id="demo"> have been parsed ^^
22nd Mar 2021, 12:51 PM
visph
visph - avatar