[Solved]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 the same argument language.
* Dogs eat the same way all pets do.
* Dogs speak differently. Dogs replace each word in a sentence withits only known language, “woof”. For example, if the sentence is “Ilike bones”, the speak() method will turn it into “woof woofwoof”.
* For BONUS points :
* Implement a second pet of your choosing thatimplements the same Pet interface. You may be creative with whateat() and speak() will do differently for your new pet.
Implement at least two test cases to make sure your Dog objectis correctly implementing the Pet interface with its own overridefunctions (if applicable). You may use the assert() method wedefined in the lecture notes page of this module or define your ownassert(). The test code can live in the same file and should createan instance of a Dog object in order to test.
// your code from part 1 and 2
var dog = new Dog(…);
// tests here
For more BONUS points, implement at least one test for your newpet.
Expert Answer
Answer to Javascript Problem: Design a Pet object. A Pet is created with a language argument string and a stomach represented by a… . . .
OR

