JavaScript-Developer-I Exam Question 21

A developer wants to use a try...catch statement to catch any error that countSheep() may throw and pass it to a handleError() function.
What is the correct implementation of the try...catch?
  • JavaScript-Developer-I Exam Question 22

    Corrected code:
    function Person() {
    this.firstName = " John " ;
    }
    Person.prototype = {
    job: x = > " Developer "
    };
    const myFather = new Person();
    const result = myFather.firstName + " " + myFather.job();
    What is the value of result after line 10 executes?
  • JavaScript-Developer-I Exam Question 23

    Code:
    01 const sayHello = (name) = > {
    02 console.log( ' Hello ' , name);
    03 };
    04
    05 const world = () = > {
    06 return ' World ' ;
    07 };
    08
    09 sayHello(world);
    This does not print " Hello World " .
    What change is needed?
  • JavaScript-Developer-I Exam Question 24

    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?
  • JavaScript-Developer-I Exam Question 25

    Refer to the following code:
    < html lang= " en " >
    < body >
    < button class= " secondary " > Save draft < /button >
    < button class= " primary " > Save and close < /button >
    < /body >
    < script >
    function displaySaveMessage(event) {
    console.log( ' Save message. ' );
    }
    function displaySuccessMessage(event) {
    console.log( ' Success message. ' );
    }
    window.onload = function() {
    document.querySelector( ' .secondary ' )
    .addEventListener( ' click ' , displaySaveMessage, true);
    document.querySelector( ' .primary ' )
    .addEventListener( ' click ' , displaySuccessMessage, true);
    }
    < /script >
    < /html >