Created
November 13, 2013 01:14
-
-
Save rjswenson/7441901 to your computer and use it in GitHub Desktop.
Basic Javascript for a constructor function, toString(), and variable. Day 1.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Computer(name, brand, year, color) { | |
this.name = name; | |
this.brand = brand; | |
this.year = year; | |
this.color = color; | |
}; | |
Computer.prototype.toString = function () { | |
return "The computer is a(n) " + this.brand + | |
" made in " + this.year + ". " + | |
"It's name is the " + this.color + " " + | |
this.name + "."; | |
}; | |
var mine = new Computer('Greyskull', 'Apple', | |
'2008', 'Silver'); | |
console.log(mine.toString()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment