27: loop the loop works but format question


The code below works.
Should there be a semicolon after the function or not? Or is a constructor function holding objects not dealt with the same way as a function?
Also, how do you format code in this window. I have tried a lot of the icons already and none seem to work! <

`// 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);



In this case there should be no semicolon after a function. if you were assigning the function to a variable then you would need one.

so if you used an assignment statement on the function such as then it would be necessary.

var Person = function (name, age) {
this.name = name;
this.age = age; 

semicolons are only necessary after assignment statements or if you have statements on the same line. In other case they are not obligatory.

Please see the following link for more information:

Regarding formating on the forum, surround your code with three back-ticks.. back-ticks are above the tab key on your keyboard, to the left of number 1.