
Untitled
By: a guest on
Jun 15th, 2012 | syntax:
JavaScript | size: 0.72 KB | hits: 26 | expires: Never
function Foo(bar) {
this.thing = bar
}
Foo.prototype.canRaep = function(other) {
return this.thing > other.thing;
}
Foo.prototype.doRaep = function(other) {
if (this.canRaep(other))
return this.thing + ' raped ' + other.thing;
return this.thing + ' could not rap ' + other.thing;
}
alfa = new Foo('the alpha')
notalfa = new Foo('bayuh')
clayton = new Foo('Clayton')
console.log(alfa.doRaep(notalfa))
console.log(alfa.doRaep(clayton))
console.log(notalfa.doRaep(clayton))
console.log(clayton.doRaep(alfa))
console.log(clayton.doRaep(notalfa))
...
the alpha raped bayuh
the alpha raped Clayton
bayuh raped Clayton
Clayton could not rap the alpha
Clayton could not rap bayuh