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: A
Recent Comments (The most recent comments are at the top.)
Stevan Zivlak - Feb 04, 2022
The right answer is A) indeed. Here is the correct code:
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());
Recent Comments (The most recent comments are at the top.)
The right answer is A) indeed. Here is the correct code:
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());
None of the options are correct. Correct output is :
This is a scarf
saleItem.description is not a function
Verified with below code -
function Item(){
this.name = 'scarf';
this.price = 55;
}
function SaleItem(){
this.name = 'shirt';
this.price = 80;
this.discount = -1;
}
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());