Question 1

Refer to the code below:
new Promise((resolve, reject) => {
const fraction = Math.random();
if( fraction >0.5) reject("fraction > 0.5, " + fraction);
resolve(fraction);
})
.then(() =>console.log("resolved"))
.catch((error) => console.error(error))
.finally(() => console.log(" when am I called?"));

When does Promise.finally on line 08 get called?
  • Question 2

    Refer to the code below:
    Function Person(firstName, lastName, eyecolor) {
    this.firstName =firstName;
    this.lastName = lastName;
    this.eyeColor = eyeColor;
    }
    Person.job = 'Developer';
    const myFather = new Person('John', 'Doe');
    console.log(myFather.job);
    What is the output after the code executes?
  • Question 3

    A test has a dependency on database.query. During the test the dependency is replaced
    with an object called database with the method, query, that returns an array. The
    developer needs to verify how many times the method was called and the arguments
    used each time.
    Which two test approaches describe the requirement?
    Choose 2 answers
  • Question 4

    In the browser, the window object is often used to assign variables that require the broadest scope in an application Node.js application does not have access to the window object by default.
    Which two methods are used to address this ?
    Choose 2 answers
  • Question 5

    A developer is wondering whether to use, Promise.then or Promise.catch, especially
    when a Promise throws an error?
    Which two promises are rejected?
    Which 2 are correct?