rendered paste body<script>function drink(beverage){ alert(this.drinks); if(this.drinks <= 10) if(Math.random() >= 0.5) { return this.name + " takes a sip of some " + beverage + "."; } else { return this.name + " chugs a bucket of " + beverage + "."; } else { return this.name + " has drank too much to have any " + beverage + "."; } bob.drinks += 1;}function eat(food){ this.foods += 1; if(this.foods <= 10) { if(Math.random() >= 0.5) { return this.name + " munches on a bit of " + food + "."; } else { return this.name + " chomps a chunk of " + food + "."; } } else { return this.name + " is too full to have any " + food + "."; }}function human(name){ this.drinks = 0; this.foods = 0; this.name = name; this.drink = drink; this.eat = eat;}function test(){ var bob = new human("Bob"); document.getElementById("msgSpan").innerHTML += "<br>" + bob.drink("Cola"); document.getElementById("msgSpan").innerHTML += "<br>" + bob.eat("Pizza");}</script><button onclick="test()">test()</button><span id="msgSpan"></span>