Question 96

A developer is creating a simple webpage with a button. When a userclicks this button for the first time, a message is displayed.
The developer wrote the JavaScript code below, but something is missing. The message gets displayed every time a user clicks the button, instead of just the first time.
01 functionlisten(event) {
02 alert ( 'Hey! I am John Doe') ;
03 button.addEventListener ('click', listen);
Which two code lines make this code work as required?
Choose 2 answers
  • Question 97

    Refer to the code snippet below:
    Let array = [1, 2, 3, 4, 4, 5, 4, 4];
    For (let i =0; i < array.length; i++)
    if (array[i] === 4) {
    array.splice(i, 1);
    }
    }
    What is the value of array after the code executes?
  • Question 98

    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"?
  • Question 99

    Universal Containers (UC) just launched anew landing page, but users complain that the website is slow. A developer found some functions any that might cause this problem. To verify this, the developer decides to execute everything and log the time each of these three suspicious functions consumes.
    Which function can the developer use to obtain the time spent by every one of the three functions?
  • Question 100

    What are two unique features of functions defined with a fat arrow as compared to normal function definition?
    Choose 2 answers