Question 41

Refer to the following code:
<html lang="en">
<body>
<div onclick = "console.log('Outer message') ;">
<button id ="myButton">CLick me<button>
</div>
</body>
<script>
function displayMessage(ev) {
ev.stopPropagation();
console.log('Inner message.');
}
const elem = document.getElementById('myButton');
elem.addEventListener('click' , displayMessage);
</script>
</html>
What will the console show when the button is clicked?
  • Question 42

    A developer at Universal Containers creates a new landing page based on HTML, CSS, and JavaScript TO ensure that visitors have a good experience, a script named personaliseContext needs to be executed when the webpage is fully loaded (HTML content and all related files ), in order to do some custom initialization.
    Which statement should be used to call personalizeWebsiteContent based on the above business requirement?
  • Question 43

    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 " Tony" to "Mr. T."?
  • Question 44

    Refer to code below:
    Const objBook = {
    Title: 'Javascript',
    };
    Object.preventExtensions(objBook);
    Const newObjBook = objBook;
    newObjectBook.author = 'Robert';
    What are the values of objBook and newObjBook respectively ?
  • Question 45

    Refer to the code below:
    01 let car1 = new promise((_, reject) =>
    02 setTimeout(reject, 2000, "Car 1 crashed in"));
    03 let car2 = new Promise(resolve => setTimeout(resolve, 1500, "Car 2
    completed"));
    04 let car3 = new Promise(resolve => setTimeout (resolve, 3000, "Car 3
    Completed"));
    05 Promise.race([car1, car2, car3])
    06 .then(value => (
    07 let result = $(value) the race. `;
    08 ))
    09 .catch( arr => (
    10 console.log("Race is cancelled.", err);
    11 ));
    What is the value of result when Promise.race executes?