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

Salesforce JavaScript-Developer-I - Salesforce Certified JavaScript Developer (JS-Dev-101)

Page: 4 / 5
Total 147 questions

A developer initiates a server with the file server.js and adds dependencies in the source code ' s package.json that are required to run the server.

Which command should the developer run to start the server locally?

A.

node start

B.

npm start

C.

npm start server.js

D.

start server.js

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. There is a new requirement for a developer to implement a description method that will return a brief description for Item and SaleItem.

01 let regItem = new Item( ' Scarf ' , 55);

02 let saleItem = new SaleItem( ' Shirt ' , 80, .1);

03 Item.prototype.description = function() { return ' This is a ' + this.name; }

04 console.log(regItem.description());

05 console.log(saleItem.description());

06

07 SaleItem.prototype.description = function() { return ' This is a discounted ' + this.name; }

What is the output when executing the code above?

A.

This is a Scarf

Uncaught TypeError: saleItem.description is not a function

This is a Scarf

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 a Scarf

Uncaught TypeError: saleItem.description is not a function

This is a Shirt

This is a discounted Shirt

Refer to the code:

01 function execute() {

02 return new Promise((resolve, reject) = > reject());

03 }

04 let promise = execute();

05

06 promise

07 .then(() = > console.log( ' Resolved1 ' ))

08 .then(() = > console.log( ' Resolved2 ' ))

09 .then(() = > console.log( ' Resolved3 ' ))

10 .catch(() = > console.log( ' Rejected ' ))

11 .then(() = > console.log( ' Resolved4 ' ));

What is the result when the Promise in the execute function is rejected?

A.

Resolved1 Resolved2 Resolved3 Rejected Resolved4

B.

Rejected

C.

Resolved1 Resolved2 Resolved3 Resolved4

D.

Rejected Resolved4

Refer to the code:

01 const exec = (item, delay) = >

02 new Promise(resolve = > setTimeout(() = > resolve(item), delay));

03

04 async function runParallel() {

05 const [result1, result2, result3] = await Promise.all(

06 [exec( ' x ' , ' 100 ' ), exec( ' y ' , ' 500 ' ), exec( ' z ' , ' 100 ' )]

07 );

08 return `parallel is done: ${result1}${result2}${result3}`;

09 }

Which two statements correctly execute runParallel()?

A.

async runParallel().then(data);

B.

runParallel().then(function(data){

return data;

});

C.

runParallel().done(function(data){

return data;

});

D.

runParallel().then(data);

A class was written to represent regular items and sale items. Code:

01 let regItem = new Item( ' Scarf ' , 55);

02 let saleItem = new SaleItem( ' Shirt ' , 80, .1);

03 Item.prototype.description = function() { return ' This is a ' + this.name; }

04 console.log(regItem.description());

05 console.log(saleItem.description());

06

07 SaleItem.prototype.description = function() { return ' This is a discounted ' + this.name; }

08 console.log(regItem.description());

09 console.log(saleItem.description());

What is the output?

A.

This is a Scarf

Uncaught TypeError: saleItem.description is not a function

This is a Shirt

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

Uncaught TypeError: saleItem.description is not a function

This is a Scarf

This is a discounted Shirt

D.

This is a Scarf

This is a Shirt

This is a discounted Scarf

This is a discounted Shirt

Refer to the code snippet:

01 let array = [1, 2, 3, 4, 4, 5, 4, 4];

02 for (let i = 0; i < array.length; i++) {

03 if (array[i] === 4) {

04 array.splice(i, 1);

05 i--;

06 }

07 }

What is the value of array after the code executes?

A.

[1, 2, 3, 4, 5, 4, 4]

B.

[1, 2, 3, 4, 4, 5, 4]

C.

[1, 2, 3, 4, 5, 4]

D.

[1, 2, 3, 5]

let sampleText = " The quick brown fox jumps " ;

Which three expressions return true for a substring?

A.

sampleText.includes( ' fox ' );

B.

sampleText.indexOf( ' quick ' ) > -1;

C.

sampleText.indexOf( ' fox ' ) !== -1;

D.

sampleText.include( ' fox ' ) !== -1;

E.

sampleText.indexOf( ' Quick ' ) !== -1;

Which statement accurately describes an aspect of promises?

A.

Arguments for the callback function passed to .then() are optional.

B.

.then() cannot be added after a catch.

C.

.then() manipulates and returns the original promise.

D.

In a .then() function, returning results is not necessary since callbacks will catch the result of a previous promise.

A developer uses a parsed JSON string to work with user information as in the block below:

01 const userInformation = {

02 " id " : " user-01 " ,

03 " email " : " user01@universalcontainers.demo " ,

04 " age " : 25

05 };

Which two options access the email attribute in the object?

A.

userInformation.email

B.

userInformation.get( " email " )

C.

userInformation[ " email " ]

D.

userInformation[email]

After user acceptance testing, the developer is asked to change the webpage background based on the user’s location. It works on the developer’s computer but not on the tester’s machine.

Which two actions will help determine accurate results?

A.

The tester should disable their browser cache.

B.

The developer should inspect their browser refresh settings.

C.

The tester should clear their browser cache.

D.

The developer should rework the code.