Valid JavaScript-Developer-I Dumps shared by ExamDiscuss.com for Helping Passing JavaScript-Developer-I Exam! ExamDiscuss.com now offer the newest JavaScript-Developer-I exam dumps, the ExamDiscuss.com JavaScript-Developer-I exam questions have been updated and answers have been corrected get the newest ExamDiscuss.com JavaScript-Developer-I dumps with Test Engine here:
A class was written to represent items for purchase in an online store, and a second class Representing items that are on sale at a discounted price. THe constructor sets the name to the first value passed in. The pseudocode is below: Class Item { constructor(name, price) { ... // Constructor Implementation } } Class SaleItem extends Item { constructor (name, price, discount) { ...//Constructor Implementation } } There is a new requirement for a developer to implement a description method that will return a brief description for Item and SaleItem. Let regItem =new Item('Scarf', 55); Let saleItem = new SaleItem('Shirt' 80, -1); Item.prototype.description = function () { return 'This is a ' + this.name; console.log(regItem.description()); console.log(saleItem.description()); SaleItem.prototype.description = function () { return 'This is a discounted ' + this.name; } console.log(regItem.description()); console.log(saleItem.description()); What is the output when executing the code above ?
Correct Answer: B
Recent Comments (The most recent comments are at the top.)
MARLU - Mar 28, 2023
class Item { constructor(name, price) { this.name = name; this.price = price; } } class SaleItem extends Item {
let regItem = new Item("Scarf", 55); let saleItem = new SaleItem("Shirt", 80, -1); Item.prototype.description = function () { return "This is a " + this.name; }; console.log(regItem.description()); console.log(saleItem.description()); SaleItem.prototype.description = function () { return "This is a discounted " + this.name; }; console.log(regItem.description()); console.log(saleItem.description());
OUTPUT:
"This is a Scarf" "This is a Shirt" "This is a Scarf" "This is a discounted Shirt"
Recent Comments (The most recent comments are at the top.)
class Item {
constructor(name, price) {
this.name = name;
this.price = price;
}
}
class SaleItem extends Item {
constructor(name, price, discount) {
super(name,price);
this.discount = discount;
}
}
let regItem = new Item("Scarf", 55);
let saleItem = new SaleItem("Shirt", 80, -1);
Item.prototype.description = function () {
return "This is a " + this.name;
};
console.log(regItem.description());
console.log(saleItem.description());
SaleItem.prototype.description = function () {
return "This is a discounted " + this.name;
};
console.log(regItem.description());
console.log(saleItem.description());
OUTPUT:
"This is a Scarf"
"This is a Shirt"
"This is a Scarf"
"This is a discounted Shirt"