Skip to content
Open

MVP #269

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 38 additions & 10 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +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 (someFood) {
if (this.stomach.legnth !== 10) {
this.stomach.push(someFood);
}
};

Person.prototype.poop = function () {
this.stomach = [];
};

Person.prototype.toString = function () {
return `${this.name}, ${this.age}`;
};

/*
TASK 2
Expand All @@ -36,10 +51,18 @@ 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;
}

Car.prototype.fill = function (gallons) {
this.tank += gallons;
};

// const greenCar = new Car(model, milesPerGallon);

/*
TASK 3
Expand All @@ -49,10 +72,15 @@ function Car() {
+ Should return a string "Playing with x", x being the favorite toy.
*/

function Baby() {

function Baby(name, age, favoriteToy) {
Person.call(this, name, age);
this.favoriteToy = favoriteToy;
}
Baby.prototype = Object.create(Person.prototype);

Baby.prototype.play = function () {
return `Playing with ${this.favoriteToy}`;
};

/*
TASK 4
Expand All @@ -66,14 +94,14 @@ function Baby() {
///////// END OF CHALLENGE /////////

/* 🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑 Please do not modify anything below this line 🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑 */
function foo(){
function foo() {
console.log('its working!');
return 'bar';
}
foo();
module.exports = {
foo,
Person,
Person,
Car,
Baby
}
Baby,
};
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.