Can anyone tell why this is code not working
var person = {fname:"John", lname:"Doe", age:25};
var text = "";
var x;
for (x in person) {
text += person.x + " ";
}
document.getElementById("demo").innerHTML = text;
If the variable is
var person = {fname:"John", lname:"Doe", age:25, x:"male"};
and var x;
is not needed.
then it will work right?