Adding methods to objects

Now that we've added our own characteristics to the babies, we need to make sure that they can do all the things that they're supposed to do, such as cry and eat. These methods can be added in the same manner as the properties:

function Baby(babySex, hairColour, eyeColour)
{
this.sex = sex;
this.hair = hairColour;
this.eyes = eyeColour;
this.cry = cry;
this.eat = eat;
}

Notice that the baby function defines baby objects, but does nothing on its own. The baby function just defines the properties and methods that baby objects will have. If we want to make a baby cry (wah ha ha!), we need to instantiate a new baby object, and then make the instantiated baby object cry:

var b3 = new Baby("Male", "Brown", "Brown", "Ned");
b3.cry();