diff --git a/index.js b/index.js index 43db2abe..3799be22 100644 --- a/index.js +++ b/index.js @@ -15,11 +15,25 @@ + It should return a string with `name` and `age`. Example: "Mary, 50" */ -function Person() { +function Person(name,age) { + this.name = name; + this.age = age; + this.stomach = []; +} +Person.prototype.eat = function(food) { + if(this.stomach.length <= 9){ + this.stomach.push(food); + } } +Person.prototype.poop = function() { + this.stomach.length = 0; +} +Person.prototype.toString = function() { + return(`${this.name}, ${this.age}`); +} /* TASK 2 - Write a Car constructor that initializes `model` and `milesPerGallon` from arguments. @@ -36,8 +50,29 @@ function Person() { + The `drive` method should return a string "I ran out of fuel at x miles!" x being `odometer`. */ -function Car() { +function Car(model,milesPerGallon) { + this.model = model; + this.milesPerGallon = milesPerGallon; + this.tank = 0; + this.odometer = 0; + this.drive = function (distance) { + let current = 0 + for(i<0;i