Medium
Either the following code:
function Creature(name, age, strength) {
this.name = name;
this.age = age;
this.strength = strength;
}
Creature.prototype.saySomething = function(words) {
console.info(this.name + 'says:' + words.toLowerCase());
}
function Orc(name, age, strength) {
Creature.call(this, name, age, strength);
}
Orc.prototype = Object.create(Creature.prototype, { constructor: { value: Orc }});
Orc.prototype.scream = function(words) {
console.info(this.name + 'screams:' + words.toUpperCase() + '!!!');
}
How could we use the ES2015(ES6) syntax to improve this code so that it gives exactly the same result?
Author: Jean-marie CléryStatus: PublishedQuestion passed 1921 times
Edit
0
Community Evaluations
Similar QuestionsMore questions about Javascript
8
Which of the following equality(s) are true? 0 == '', 'f' + 1 == 'f1'7
Write a Javascript code that prints the indexes of an array.6
Invert a string in Javascript6
Which of the following is the **most optimized** method for creating a literal object?5
What is the value of `obj.hello` after executing these few lines of code?