ExamGecko
Ask Question

Salesforce Certified JavaScript Developer I Practice Test - Questions Answers, Page 6

Add to Whishlist

List of questions

Question 51

Report Export Collapse

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 ?
.//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 ?
This is a ScarfUncaught TypeError: saleItem.description is not a functionThis is aScarfThis is a discounted Shirt
This is a ScarfUncaught TypeError: saleItem.description is not a functionThis is aScarfThis is a discounted Shirt
This is a ScarfThis is a ShirtThis is a ScarfThis is a discounted Shirt
This is a ScarfThis is a ShirtThis is a ScarfThis is a discounted Shirt
This is a ScarfThis is a ShirtThis is a discounted ScarfThis is a discounted Shirt
This is a ScarfThis is a ShirtThis is a discounted ScarfThis is a discounted Shirt
This is aScarfUncaught TypeError: saleItem.description is not a functionThis is a ShirtThis is a did counted Shirt
This is aScarfUncaught TypeError: saleItem.description is not a functionThis is a ShirtThis is a did counted Shirt
Suggested answer: B
asked 23/09/2024
Nivenl Surnder
37 questions

Question 52

Report Export Collapse

Given the following code:

Let x =('15' + 10)*2;

What is the value of a?

3020
3020
1520
1520
50
50
35
35
Suggested answer: A
asked 23/09/2024
Justin Schowalter
41 questions

Question 53

Report Export Collapse

Refer to the following code:

01 function Tiger(){

02 this.Type = 'Cat';

03 this.size = 'large';

04 }

05

06 let tony = new Tiger();

07 tony.roar = () =>{

08 console.log('They\'re great1');

09 };

10

11 function Lion(){

12 this.type = 'Cat';

13 this.size = 'large';

14 }

15

16 let leo = new Lion();

17 //Insert code here

18 leo.roar();

Which two statements could be inserted at line 17 to enable the function call on line 18?

Choose 2 answers.

Leo.roar = () => { console.log('They\'re pretty good:'); };
Leo.roar = () => { console.log('They\'re pretty good:'); };
Object.assign(leo,Tiger);
Object.assign(leo,Tiger);
Object.assign(leo,tony);
Object.assign(leo,tony);
Leo.prototype.roar = () => { console.log('They\'re pretty good:'); };
Leo.prototype.roar = () => { console.log('They\'re pretty good:'); };
Suggested answer: A, C
asked 23/09/2024
Jag Patel
37 questions

Question 54

Report Export Collapse

Which statement accurately describes an aspect of promises?

Arguments for the callback function passed to .then() are optional.
Arguments for the callback function passed to .then() are optional.
In a.then() function, returning results is not necessary since callbacks will catch the result of a previous promise.
In a.then() function, returning results is not necessary since callbacks will catch the result of a previous promise.
.then() cannot be added after a catch.
.then() cannot be added after a catch.
.then() manipulates and returns the original promise.
.then() manipulates and returns the original promise.
Suggested answer: A
asked 23/09/2024
P B
43 questions

Question 55

Report Export Collapse

Given the code below:

Function myFunction(){

A =5;

Var b =1;

} myFunction();

console.log(a);

console.log(b);

What is the expected output?

Both lines 08 and 09 are executed, and the variables are outputted.
Both lines 08 and 09 are executed, and the variables are outputted.
Line 08 outputs the variable, but line 09 throws an error.
Line 08 outputs the variable, but line 09 throws an error.
Line 08 thrones an error, therefore line 09 is never executed.
Line 08 thrones an error, therefore line 09 is never executed.
Both lines 08 and 09 are executed, but values outputted are undefined.
Both lines 08 and 09 are executed, but values outputted are undefined.
Suggested answer: B
asked 23/09/2024
john rosselot
44 questions

Question 56

Report Export Collapse

Which two console logs outputs NaN ?

Choose 2 answers

console.log(10/ Number('5'));
console.log(10/ Number('5'));
console.log(parseInt('two'));
console.log(parseInt('two'));
console.log(10/ ''five);
console.log(10/ ''five);
console.log(10/0);
console.log(10/0);
Suggested answer: B, C
asked 23/09/2024
Nicholas Roy
52 questions

Question 57

Report Export Collapse

Given the following code:

Counter = 0;

const logCounter = () => {

console.log(counter);

);

logCounter();

setTimeout(logCOunter, 1100);

setInterval(() => {

Counter++

logCounter();

}, 1000);

What is logged by the first four log statements?

0 0 1 2
0 0 1 2
0 1 2 3
0 1 2 3
0 1 1 2
0 1 1 2
0 1 2 2
0 1 2 2
Suggested answer: C
asked 23/09/2024
HAO KANG SUNG
41 questions

Question 58

Report Export Collapse

Refer to the code below:

Refer to the code below:

Function Person(firstName, lastName, eyecolor) {

this.firstName =firstName;

this.lastName = lastName;

this.eyeColor = eyeColor;

}

Person.job = 'Developer';

const myFather = new Person('John', 'Doe');

console.log(myFather.job);

What is the output after the code executes?

ReferenceError: eyeColor is not defined
ReferenceError: eyeColor is not defined
ReferenceError: assignment to undeclared variable "Person"
ReferenceError: assignment to undeclared variable "Person"
Developer
Developer
Undefined
Undefined
Suggested answer: D
asked 23/09/2024
Andrea Ciovati
43 questions

Question 59

Report Export Collapse

A developer at Universal Containers creates a new landing page based on HTML, CSS, and JavaScript TO ensure that visitors have a good experience, a script named personaliseContext needs to be executed when the webpage is fully loaded (HTML content and all related files ), in order to do some custom initialization.

Which statement should be used to call personalizeWebsiteContent based on the above business requirement?

document.addEventListener(''onDOMContextLoaded', personalizeWebsiteContext);
document.addEventListener(''onDOMContextLoaded', personalizeWebsiteContext);
window.addEventListener('load',personalizeWebsiteContext);
window.addEventListener('load',personalizeWebsiteContext);
window.addEventListener('onload', personalizeWebsiteContext);
window.addEventListener('onload', personalizeWebsiteContext);
Document.addEventListener('''DOMContextLoaded' , personalizeWebsiteContext);
Document.addEventListener('''DOMContextLoaded' , personalizeWebsiteContext);
Suggested answer: B
asked 23/09/2024
Pang Guo Ming
35 questions

Question 60

Report Export Collapse

A developer is leading the creation of a new browser application that will serve a single page application. The team wants to use a new web framework Minimalsit.js. The Lead developer wants to advocate for a more seasoned web framework that already has a community around it.

Which two frameworks should the lead developer advocate for?

Choose 2 answers

Vue
Vue
Angular
Angular
Koa
Koa
Express
Express
Suggested answer: B, D
asked 23/09/2024
Donald Bell
33 questions
Total 224 questions
Go to page: of 23
Search

Related questions