Summer Certification Special Limited Time 70% Discount Offer - Ends in 0d 00h 00m 00s - Coupon code: force70

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

Viewing page 4 out of 5 pages
Viewing questions 31-40 out of questions
Questions # 31:

A developer is creating a simple webpage with a button. When a user clicks this button for the first time, a message is displayed.

The developer wrote the JavaScript code below, but something is missing. The message gets displayed every time a user clicks the button, instead of just the first time.

01 function listen(event) {

02

03 alert( ' Hey! I am John Doe ' );

04

05 }

06 button.addEventListener( ' click ' , listen);

Which two code lines make this code work as required?

Options:

A.

On line 04, use event.stopPropagation();


B.

On line 02, use event.first to test if it is the first execution.


C.

On line 06, add an option called once to button.addEventListener().


D.

On line 04, use button.removeEventListener( ' click ' , listen);


Expert Solution
Questions # 32:

A developer removes the HTML class attribute from the checkout button, so now it is simply:

< button > Checkout < /button >

There is a test to verify the existence of the checkout button, however it looks for a button with class= " blue " . The test fails because no such button is found.

Which type of test category describes this test?

Options:

A.

True negative


B.

True positive


C.

False negative


D.

False positive


Expert Solution
Questions # 33:

Which three browser specific APIs are available for developers to persist data between page loads?

Options:

A.

localStorage


B.

indexedDB


C.

cookies


D.

global variables


E.

IIFEs


Expert Solution
Questions # 34:

A developer wrote the following code to test a sum3 function that takes in an array of numbers and returns the sum of the first three numbers in the array. The test passes:

01 let res = sum3([1, 2, 3]);

02 console.assert(res === 6);

03

04 res = sum3([1, 2, 3, 4]);

05 console.assert(res === 6);

A different developer made changes to the behavior of sum3 to instead sum all of the numbers present in the array.

Which two results occur when running the test on the updated sum3 function?

Options:

A.

The line 02 assertion fails.


B.

The line 05 assertion passes.


C.

The line 05 assertion fails.


D.

The line 02 assertion passes.


Expert Solution
Questions # 35:

Given the HTML below:

< div >

< div id= " row-uc " > Universal Containers < /div >

< div id= " row-as " > Applied Shipping < /div >

< div id= " row-bt " > Burlington Textiles < /div >

< /div >

Which statement adds the priority-account CSS class to the Applied Shipping row?

Options:

A.

document.querySelectorAll( ' #row-as ' ).classList.add( ' priority-account ' );


B.

document.querySelector( ' #row-as ' ).classList.add( ' priority-account ' );


C.

document.querySelector( ' #row-as ' ).classes.push( ' priority-account ' );


D.

document.getElementById( ' row-as ' ).addClass( ' priority-account ' );


Expert Solution
Questions # 36:

A developer copied a JavaScript object:

01 function Person() {

02 this.firstName = " John " ;

03 this.lastName = " Doe " ;

04 this.name = () = > `${this.firstName},${this.lastName}`;

05 }

06

07 const john = new Person();

08 const dan = Object.assign({}, john);

09 dan.firstName = ' Dan ' ;

How does the developer access dan ' s firstName, lastName?

Options:

A.

dan.firstName() + dan.lastName()


B.

dan.name()


C.

dan.name


D.

dan.firstName + dan.lastName


Expert Solution
Questions # 37:

Refer to the code below:

01 async function functionUnderTest(isOK) {

02 if (isOK) return ' OK ' ;

03 throw new Error( ' not OK ' );

04 }

Which assertion accurately tests the above code?

Options:

A.

console.assert(await functionUnderTest(true), ' OK ' )


B.

console.assert(await (functionUnderTest(true), ' not OK ' ))


C.

console.assert(functionUnderTest(true), ' OK ' )


D.

console.assert(await functionUnderTest(true), ' not OK ' )


Expert Solution
Questions # 38:

01 function Animal(size, type) {

02 this.type = type || ' Animal ' ;

03 this.canTalk = false;

04 }

05

06 Animal.prototype.speak = function() {

07 if (this.canTalk) {

08 console.log( " It spoke! " );

09 }

10 };

11

12 let Pet = function(size, type, name, owner) {

13 Animal.call(this, size, type);

14 this.size = size;

15 this.name = name;

16 this.owner = owner;

17 }

18

19 Pet.prototype = Object.create(Animal.prototype);

20 let pet1 = new Pet();

Given the code above, which three properties are set for pet1?

Options:

A.

speak


B.

owner


C.

canTalk


D.

name


E.

type


Expert Solution
Questions # 39:

Refer to the code below:

let productSKU = ' 8675309 ' ;

A developer has a requirement to generate SKU numbers that are always 19 characters long, starting with ' sku ' , and padded with zeros.

Which statement assigns the value sku000000008675309?

Options:

A.

productSKU = productSKU.padEnd(16, ' 0 ' ).padStart( ' sku ' );


B.

productSKU = productSKU.padStart(16, ' 0 ' ).padStart(19, ' sku ' );


C.

productSKU = productSKU.padEnd(16, ' 0 ' ).padStart(19, ' sku ' );


D.

productSKU = productSKU.padStart(19, ' 0 ' ).padStart( ' sku ' );


Expert Solution
Questions # 40:

A team at Universal Containers works on a big project and uses Yarn to deal with the project’s dependencies. A developer added a dependency to manipulate dates and pushed the updates to the remote repository. The rest of the team complains that the dependency does not get downloaded when they execute yarn.

What could be the reason for this?

Options:

A.

The developer missed the option --add when adding the dependency.


B.

The developer added the dependency as a dev dependency, and NODE_ENV is set to production.


C.

The developer added the dependency as a dev dependency, and YARN_ENV is set to production.


D.

The developer missed the option --save when adding the dependency.


Expert Solution
Viewing page 4 out of 5 pages
Viewing questions 31-40 out of questions