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 # 11

Refer to the code below:

< html >

< body >

< div id= " logo " > Hello Logo! < /div >

< button id= " test " > Click me < /button >

< /body >

< script >

function printMessage(event) {

console.log( ' This is a test message ' );

}

let el = document.getElementById( ' test ' );

el.addEventListener( " click " , printMessage, false);

< /script >

< /html >

Which action should be done?

Options:

A.  

Add event.removeEventListener(); to window.onload event handler

B.  

Add event.removeEventListener(); to printMessage function

C.  

Add event.stopPropagation(); to printMessage function

D.  

Add event.stopPropagation(); to window.onload event handler

Discussion 0
Question # 12

function myFunction() {

a = a + b;

var b = 1;

}

myFunction();

console.log(a);

console.log(b);

Which statement is correct?

Options:

A.  

Line 02 throws a reference error, therefore line 03 is never executed.

B.  

Both line 02 and 03 are executed, but the values printed are undefined.

C.  

Both line 02 and 03 are executed, and the variables are hoisted.

D.  

Line 08 outputs the variable, but line 09 throws an error.

Discussion 0
Question # 13

Refer to the code below:

01 < html lang= " en " >

02 < table onclick= " console.log( ' Table log ' ); " >

03 < tr id= " row1 " >

04 < td > Click me! < /td >

05 < /tr >

06 < /table >

07 < script >

08 function printMessage(event) {

09 console.log( ' Row log ' );

10 event.stopPropagation();

11 }

12

13 let elem = document.getElementById( ' row1 ' );

14 elem.addEventListener( ' click ' , printMessage, false);

15 < /script >

16 < /html >

Which code change should be done for the console to log the following when " Click me! " is clicked?

Row log

Table log

Options:

A.  

Change line 14 to elem.addEventListener( ' click ' , printMessage, true);

B.  

Remove lines 13 and 14

C.  

Change line 10 to event.stopPropagation(false);

D.  

Remove line 10

Discussion 0
Question # 14

A developer has a fizzbuzz function that, when passed in a number, returns the following:

    ' fizz ' if the number is divisible by 3.

    ' buzz ' if the number is divisible by 5.

    ' fizzbuzz ' if the number is divisible by both 3 and 5.

    Empty string if the number is divisible by neither 3 nor 5.

Which two test cases properly test scenarios for the fizzbuzz function?

Options:

A.  

let res = fizzbuzz(3);

console.assert(res === ' buzz ' );

B.  

let res = fizzbuzz(15);

console.assert(res === ' fizzbuzz ' );

C.  

let res = fizzbuzz(NaN);

console.assert(isNaN(res));

D.  

let res = fizzbuzz(Infinity);

console.assert(res === ' ' );

Discussion 0
Question # 15

A developer wrote the following code:

01 let x = object.value;

02

03 try {

04 handleObjectValue(x);

05 } catch(error) {

06 handleError(error);

07 }

The developer has a getNextValue function to execute after handleObjectValue(), but does not want to execute getNextValue() if an error occurs. How can the developer change the code to ensure this behavior?

Options:

A.  

03 try {

04 handleObjectValue(x);

05 } catch(error) {

06 handleError(error);

07 } then {

08 getNextValue();

09 }

B.  

03 try {

04 handleObjectValue(x);

05 getNextValue();

06 } catch(error) {

07 handleError(error);

08 }

C.  

03 try {

04 handleObjectValue(x);

05 } catch(error) {

06 handleError(error);

07 }

08 getNextValue();

D.  

03 try {

04 handleObjectValue(x);

05 } catch(error) {

06 handleError(error);

07 } finally {

08 getNextValue();

09 }

Discussion 0
Question # 16

Refer to the code declarations below:

let str1 = ' Java ' ;

let str2 = ' Script ' ;

Which three expressions return the string JavaScript?

Options:

A.  

`${str1}${str2}`

B.  

str1.concat(str2);

C.  

const({str1, str2});

D.  

str1 + str2;

E.  

str1.join(str2);

Discussion 0
Question # 17

Console logging methods that allow string substitution:

Options:

A.  

message

B.  

log

C.  

assert

D.  

info

E.  

error

Discussion 0
Question # 18

A developer has two ways to write a function:

Option A:

01 function Monster() {

02 this.growl = () = > {

03 console.log( " Grr! " );

04 }

05 }

Option B:

01 function Monster() {};

02 Monster.prototype.growl = () = > {

03 console.log( " Grr! " );

04 }

After deciding on an option, the developer creates 1000 monster objects. How many growl methods are created with Option A and Option B?

Options:

A.  

1000 growl methods are created regardless of which option is used.

B.  

1 growl method is created regardless of which option is used.

C.  

1000 growl methods are created for Option

A.  

1 growl method is created for Option

B.  

D.  

1 growl method is created for Option

A.  

1000 growl methods are created for Option

B.  

Discussion 0
Question # 19

Refer to the HTML below:

< div id= " main " >

< ul >

< li > Leo < /li >

< li > Tony < /li >

< li > Tiger < /li >

< /ul >

< /div >

Which JavaScript statement results in changing " Leo " to " The Lion " ?

Options:

A.  

document.querySelectorAll( ' #main #Leo ' ).innerHTML = ' The Lion ' ;

B.  

document.querySelector( ' #main li:second-child ' ).innerHTML = ' The Lion ' ;

C.  

document.querySelectorAll( ' #main li,Leo ' ).innerHTML = ' The Lion ' ;

D.  

document.querySelector( ' #main li:nth-child(1) ' ).innerHTML = ' The Lion ' ;

Discussion 0
Question # 20

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

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