Skip to content

Instantly share code, notes, and snippets.

@rjswenson
Created November 13, 2013 01:14
Show Gist options
  • Save rjswenson/7441901 to your computer and use it in GitHub Desktop.
Save rjswenson/7441901 to your computer and use it in GitHub Desktop.
Basic Javascript for a constructor function, toString(), and variable. Day 1.
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