Pre-Winter Sale Limited Time 65% Discount Offer - Ends in 0d 00h 00m 00s - Coupon code: 65pass65

Free Salesforce Certified JavaScript Developer (JS-Dev-101) Practice Questions

Question # 21

Code:

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 execution?

Options:

A.  

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

B.  

[1,2,3,5]

C.  

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

D.  

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

Discussion 0
Question # 22

Refer to the code below:

01 const objBook = {

02 title: ' JavaScript ' ,

03 };

04 Object.preventExtensions(objBook);

05 const newObjBook = objBook;

06 newObjBook.author = ' Robert ' ;

What are the values of objBook and newObjBook respectively?

Options:

A.  

{ title: " JavaScript " }

{ title: " JavaScript " }

B.  

{ author: " Robert " , title: " JavaScript " }

undefined

C.  

{ author: " Robert " }

{ author: " Robert " , title: " JavaScript " }

D.  

{ author: " Robert " , title: " JavaScript " }

{ author: " Robert " , title: " JavaScript " }

Discussion 0
Question # 23

Given two expressions var1 and var2, what are two valid ways to return the concatenation of the two expressions and ensure it is data type string?

Options:

A.  

String(var1).concat(var2)

B.  

String.concat(var1 + var2)

C.  

var1 + var2

D.  

var1.toString() + var2.toString()

Discussion 0
Question # 24

Refer to the code below:

01 let o = {

02 get js() {

03 let city1 = String( ' St. Louis ' );

04 let city2 = String( ' New York ' );

05

06 return {

07 firstCity: city1.toLowerCase(),

08 secondCity: city2.toLowerCase(),

09 }

10 }

11 }

What value can a developer expect when referencing o.js.secondCity?

Options:

A.  

undefined

B.  

An error

C.  

' New York '

D.  

' new york '

Discussion 0
Question # 25

Refer to the following array:

let arr = [1, 2, 3, 4, 5];

Which two lines of code result in a second array, arr2, created such that arr2 is a reference to arr?

Options:

A.  

let arr2 = arr.slice(0, 5);

B.  

let arr2 = Array.from(arr);

C.  

let arr2 = arr;

D.  

let arr2 = arr.sort();

Discussion 0
Question # 26

Refer to the following code block:

01 let array = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11];

02 let output = 0;

03

04 for (let num of array) {

05 if (output > 10) {

06 break;

07 }

08 if (num % 2 == 0) {

09 continue;

10 }

11 output += num;

12 }

What is the value of output after the code executes?

Options:

A.  

16

B.  

25

C.  

11

D.  

36

Discussion 0
Question # 27

Refer to the code below:

01 new Promise((resolve, reject) = > {

02 const fraction = Math.random();

03 if (fraction > 0.5) reject( ' fraction > 0.5, ' + fraction);

04 resolve(fraction);

05 })

06 .then(() = > console.log( ' resolved ' ))

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

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

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

Discussion 0
Question # 28

Refer to the code below (assuming Promise.race is intended):

let cat3 = new Promise(resolve = >

setTimeout(resolve, 3000, " Cat 3 completes " )

);

Promise.race([cat1, cat2, cat3])

.then(value = > {

let result = `${value} the race.`;

})

.catch(err = > {

console.log( " Race is cancelled: " , err);

});

(Assuming cat1 and cat2 are similar to earlier examples: cat2 resolves fastest.)

What is the value of result when Promise.race executes?

Options:

A.  

Car 2 completed the race.

B.  

Car 1 crashed on the race.

C.  

Race is cancelled.

D.  

Car 3 completed the race.

Discussion 0
Question # 29

Refer to the following code:

01 class Ship {

02 constructor(size) {

03 this.size = size;

04 }

05 }

06

07 class FishingBoat extends Ship {

08 constructor(size, capacity){

09 //Missing code

10 this.capacity = capacity;

11 }

12 displayCapacity() {

13 console.log( ' The boat has a capacity of ${this.capacity} people. ' );

14 }

15 }

16

17 let myBoat = new FishingBoat( ' medium ' , 10);

18 myBoat.displayCapacity();

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);

B.  

ship.size = size;

C.  

super.size = size;

D.  

this.size = size;

Discussion 0
Question # 30

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

Discussion 0

JavaScript-Developer-I PDF

JavaScript-Developer-I PDF (Printable)
$54.25
$154.99

JavaScript-Developer-I Testing Engine

JavaScript-Developer-I PDF (Printable)
$59.5
$169.99

JavaScript-Developer-I PDF + Testing Engine

JavaScript-Developer-I PDF (Printable)
$74.55
$212.99

Free Exams Sample Questions