I'm a newbie with js/html, was nearing the completion of this small project when this error showed up after i added the "document.getElementById" tags.
This is the image which shows the error in the console
and the following is the function that im writing and the object that it is referring.
for(const key1 in reservedSeats){
if(reservedSeats.hasOwnProperty(key1)){
const obj=reservedSeats[key1];
console.log(obj.seat)//checking to see if it returns the seat number
document.getElementById(obj.seat).className="r";
document.getElementById(obj.seat).innerHTML='R';
}
}
var reservedSeats = {
record1: {
seat: "b19",
owner: {
fname: "Joe",
lname: "Smith"
}
},
record2: {
seat: "b20",
owner: {
fname: "Joe",
lname: "Smith"
}
},
record3: {
seat: "b21",
owner: {
fname: "Joe",
lname: "Smith"
}
},
record4: {
seat: "b22",
owner: {
fname: "Joe",
lname: "Smith"
}
}
};
saw multiple stackof saying that the object needs to be above the "getelementbyid" tag, have done that and it still doesn't work.