Pass the Salesforce Salesforce Developer JavaScript-Developer-I Questions and answers with CertsForce

Viewing page 3 out of 7 pages
Viewing questions 21-30 out of questions
Questions # 21:

Referto the code below:

new Promise((resolve, reject) => {

const fraction = Math.random();

if( fraction >0.5) reject("fraction > 0.5, " + fraction);

resolve(fraction);

})

.then(() =>console.log("resolved"))

.catch((error) => console.error(error))

.finally(() =>console.log(" when am I called?"));

Question # 21

When does Promise.finally on line 08 get called?

Options:

A.

When rejected


B.

When resolved and settled


C.

When resolved


D.

When resolved or rejected


Expert Solution
Questions # 22:

A developer at Universal Containers creates a new landing page based on HTML, CSS, and

JavaScript TO ensure that visitors have a goodexperience, 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 onthe above

business requirement?

Options:

A.

document.addEventListener(‘’onDOMContextLoaded’, personalizeWebsiteContext);


B.

window.addEventListener(‘load’,personalizeWebsiteContext);


C.

window.addEventListener(‘onload’, personalizeWebsiteContext);


D.

Document.addEventListener(‘‘’DOMContextLoaded’ , personalizeWebsiteContext);


Expert Solution
Questions # 23:

A developer wants to iterate through an array of objects and count the objects and count

the objects whose property value, name, starts with the letterN.

Const arrObj = [{“name” : “Zach”} , {“name” : “Kate”},{“name” : “Alise”},{“name” : “Bob”},{“name” :

“Natham”},{“name” : “nathaniel”}

Refer to the code snippet below:

01 arrObj.reduce(( acc, curr) => {

02 //missing line 02

02 //missing line 03

04 ). 0);

Which missing lines 02 and 03 return the correct count?

Options:

A.

Const sum = curr.startsWith(‘N’) ? 1: 0;Return acc +sum


B.

Const sum = curr.name.startsWith(‘N’) ? 1: 0;Return acc +sum


C.

Const sum = curr.startsWIth(‘N’) ? 1: 0;Return curr+ sum


D.

Const sum =curr.name.startsWIth(‘N’) ? 1: 0;Return curr+ sum


Expert Solution
Questions # 24:

Refer tofollowing code:

class Vehicle {

constructor(plate) {

This.plate =plate;

}

}

Class Truck extends Vehicle {

constructor(plate, weight) {

//Missing code

This.weight = weight;

}

displayWeight() {

console.log(‘The truck ${this.plate} has a weight of${this.weight} lb.’);}}

Let myTruck = new Truck(‘123AB’, 5000);

myTruck.displayWeight();

Which statement should be added to line 09 for the code to display ‘The truck 123AB has a

weight of 5000lb.’?

Options:

A.

Super.plate =plate;


B.

super(plate);


C.

This.plate =plate;


D.

Vehicle.plate = plate;


Expert Solution
Questions # 25:

Refer to the following code:

Question # 25

Which statement should be added to line 09 for the code to display. The boat has a capacity of 10 people?

Options:

A.

super.size = size;


B.

ship.size size;


C.

super (size);


D.

this.size = size;


Expert Solution
Questions # 26:

Refer to the following object.

Question # 26

How can a developer access the fullName property for dog?

Options:

A.

Dog.fullName


B.

Dog.fullName ( )


C.

Dog, get,fullName


D.

Dog, function, fullName


Expert Solution
Questions # 27:

Given the following code:

document.body.addEventListener(‘ click ’, (event) => {

if (/* CODE REPLACEMENT HERE */) {

console.log(‘button clicked!’);

)

});

Which replacement for the conditional statement on line 02 allows a developer to

correctly determine that a button on page is clicked?

Options:

A.

Event.clicked


B.

e.nodeTarget ==this


C.

event.target.nodeName == ‘BUTTON’


D.

button.addEventListener(‘click’)


Expert Solution
Questions # 28:

A developer is leading the creation of a new web server for their team that will fulfill API requests from an existing client.

The team wants a web server that runs on Node.Js, and they want to use the new web framework Minimalist.Js. The lead developer wants to advocate for a more seasoned back-end framework that already has a community around it.

Which two frameworks could the lead developer advocate for?

Choose 2 answers

Options:

A.

Gatsby


B.

Angular


C.

Express


D.

Koa


Expert Solution
Questions # 29:

Given the JavaScript below:

Question # 29

Which code should replace the placeholder comment on line 05 to highlight accounts that match the search string'

Options:

A.

'yellow' : null


B.

null : 'yellow’


C.

'none1 : "yellow’


D.

'yellow : 'none'


Expert Solution
Questions # 30:

Universal Containers (UC) notices that its application that allows users to search for

accounts makes a network request each time a key is pressed. This results in too many

requests for the server to handle.

● Address this problem, UC decides to implement a debounce function on string change

handler.

What are three key steps to implement this debounce function?

Choose 3 answers:

Options:

A.

If there is an existing setTimeout and the search string change, allow the existingsetTimeout to finish, and do not enqueue a new setTimeout.


B.

When thesearch string changes, enqueue the request within a setTimeout.


C.

Ensure that the network request has the property debounce set to true.


D.

If there is an existing setTimeout and the search string changes, cancel the existingsetTimeout using thepersisted timerId and replace it with a new setTimeout.


E.

Store the timeId of the setTimeout last enqueued by the search string change handle.


Expert Solution
Viewing page 3 out of 7 pages
Viewing questions 21-30 out of questions