Javascript Problem Design Pet Object Pet Created Language Argument String Stomach Represen Q37034979

Javascript Problem:

Design a Pet object. A Pet is created with a language argumentstring and a stomach represented by an array. The Pet shouldsupport functions: eat() and speak(). Use the prototype property todefine your object’s interface.
eat(food) will store the passed argument into its stomach andreturn what it has eaten thus far.
speak(sentence) will simply return the passed in phrase.
function Pet(language) {
// create stomach
// set language
}

// takes a food_item STRING and returns everything eaten so farARRAY
Pet.prototype.eat(food_item){
// … complete
}

// takes in a sentence STRING and returns the passed in sentenceSTRING with no change
Pet.prototype.speak(sentence){
// … complete
}

Create an object, Dog, that implements the Pet interface andtakes

OR
OR

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.