Notifications
Clear all

The pseudocode is below:

1 Posts
1 Users
0 Likes
93 Views
(@baumgarnerisreal)
Posts: 677
Noble Member
Topic starter
 

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?

  • A . This is a Scarf
    Uncaught TypeError: saleItem.description is not a function
    This is aScarf
    This is a discounted Shirt
    B. This is a Scarf
    This is a Shirt
    This is a Scarf
    This is a discounted Shirt
    C. This is a Scarf
    This is a Shirt
    This is a discounted Scarf
    This is a discounted Shirt
    D. This is aScarf
    Uncaught TypeError: saleItem.description is not a function
    This is a Shirt
    This is a did counted Shirt

Show Answer Hide Answer

Suggested Answer: B
 
Posted : 31/01/2023 12:36 pm

Latest Salesforce JavaScript Developer I Dumps Valid Version

Latest And Valid Q&A | Instant Download | Once Fail, Full Refund
Share: