So I'm trying to run a for loop to update several objects variables and using an array of their names but the reference doesn't work and instead appears undefined. I presume this is because the array is a string and not an object and was wondering what the easiest way around this would be.
I've attached some simple code to give you an idea what i'm attempting, cheers.
<!DOCTYPE html>
<html>
<body>
<p id="demo"></p>
<script>
var person1 = {
firstName : "John",
lastName : "Doe",
age : 50,
eyeColor : "blue"
};
var person2 = {
firstName : "Bill",
lastName : "Smith",
age : 32,
eyeColor : "brown"
};
var people = ["person","person2"];
document.getElementById("demo").innerHTML =
people[0].age
</script>
</body>
</html>