27/33 Loop The Loop is making me loopy!


#1

// Our Person constructor
function Person (name, age) {
this.name = name;
this.age = age;
}
// Now we can make an array of people
var family = new Array();
family[0] = new Person("alice", 40);
family[1] = new Person("bob", 42);
family[2] = new Person("michelle", 8);
family[3] = new Person("timmy", 6);

// loop through our new array
for(var i = 0, i <= family.length, i++) {
console.log("My name is " + family[i].name);
}

// never mind, i found the problem. I should've used semi-colons inside my for loop


#2

Maybe you could have closed your Post as solution-found....


#3

leonhard_wettengmx_n - I sincerely apologise. I did look for a way to close the post but there was no control to do so? the only controls are to share, flag, edit, or bookmark? Again. apologies.


#4

I found my problem. So I am deleting zhis post.


#5

Your post helped me solve my problem, especially the following line:

console.log(family[i].name);


#6

If they close their post then people who have the same problem have to ask again instead of just looking up the answer.


#7

@datarockstar64796,
IMHO
If the Post is marked as Solved === closed
it will be archived (not yet activated ??) .....

In the search-facilty
you could then use
"family[0]" status:closed
or
"function Person" status:open


#8

for(var i = 0, i <= family.length, i++)
error

the correct is
for(var i = 0; i <= family.length; i++)