Deal of The Day! Hurry Up, Grab the Special Discount - Save 25% - Ends In 00:00:00 Coupon code: SAVE25
Welcome to Pass4Success

- Free Preparation Discussions

Salesforce JS-Dev-101 Exam - Topic 1 Question 12 Discussion

Refer to the code below:01 02 03 04 Click me!05 06 07 08 function printMessage(event) {09 console.log('Row log');10 event.stopPropagation();11 }1213 let elem = document.getElementById('row1');14 elem.addEventListener('click', printMessage, false);15 16 Which code change should be done for the console to log the following when "Click me!" is clicked?Row logTable log
D) Remove line 10
A) Change line 14 to elem.addEventListener('click', printMessage, true);
B) Remove lines 13 and 14
C) Change line 10 to event.stopPropagation(false);

Salesforce JS-Dev-101 Exam - Topic 1 Question 12 Discussion

Actual exam question for Salesforce's JS-Dev-101 exam
Question #: 12
Topic #: 1
[All JS-Dev-101 Questions]

Refer to the code below:

01

02

03

04

05

06

Click me!

07

16

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

Row log

Table log

Show Suggested Answer Hide Answer
Suggested Answer: D

Current behavior:

Clicking <td> triggers the click event on row1, then bubbles up to <table>.

printMessage runs, logs 'Row log', then event.stopPropagation() stops the event from bubbling to the table.

So 'Table log' never appears.

To allow the table's inline onclick to run after the row handler:

Remove the propagation stop:

function printMessage(event) {

console.log('Row log');

// event.stopPropagation(); // remove this

}

Now the event bubbles:

printMessage logs 'Row log'.

The table's onclick runs, logging 'Table log'.

Option A only changes capture/bubble phase but still stops propagation. C does nothing meaningful (stopPropagation takes no arguments). B removes the row handler entirely.


Contribute your Thoughts:

0/2000 characters

Currently there are no comments in this discussion, be the first to comment!


Save Cancel