// // space.js // // spaceShip prototype function spaceShip(_name, _clazz, _creator, _hp, _homeWorld) { this.name = _name; this.clazz = _clazz; this.creator = _creator; this.hp = _hp; this.color = "Silver" if (_homeWorld === undefined) { this.homeWorld = "Hoth"; } else { this.homeWorld = _homeWorld; } this.toString = function() { var retVal = ""; retVal = "[spaceShip]" + "\n" + "name:" + this.name + "\n" + "class:" + this.clazz + "\n" + "creator:" + this.creator + "\n" + "horse power:" + this.hp + "\n" + "color:" + this.color + "\n" + "home world:" + this.homeWorld + "\n"; return retVal; } } function tester() { // create myShip as an instance of the spaceShip prototype. myShip = new spaceShip("Alan", "CS-1", "Kirok", 1.5, "Earth"); yourShip = new spaceShip("Justin", "Bashful", "Sleepy", "Dopey"); updateText(myShip); updateText(yourShip); yourShip.color = "White"; updateText(yourShip); }