Are you ready?

1 questions to solve.

Instructions
  1. This quiz goes to full-screen once you press the Start button, or any Next button after exiting the quiz window.
  2. At the end of the quiz, you are able to review all the questions that you answered wrong and see their explanations.
What is the value of the promise p3 in the code below?
var p = new Promise(function() {
    return "OK";
});

var p2 = p.then(function(data) {
    return data;
});

var p3 = p2.then(function(data) {
    return data + " Bye";
});
What log will be made by the following code, after 2 seconds?
var p = new Promise(function(resolve, reject) {
    setTimeout(function() {
        resolve("OK");
    }, 2000);
});

p.then().then(function(data) {
    console.log(data);
});
The status property is filled with the value 200, starting at readyState equal to 2. Therefore this.status == 200 returns true for the states 2, 3 and 4; that sum up of three all together.
Determine the value of the promise p2 shown below after resolve("OK") is called (in line 3).
var p = new Promise(function(resolve, reject) {
    setTimeout(function() {
        resolve("OK");
    }, 2000);
}).
then();

var p2 = p.then(function(data) {
    return data + " Good";
})
All the names shown below are invalid, except for the second one i.e XMLHttpRequest(). See Mechanism of AJAX for more info.
Determine the state and value of the promise p in the following code.
var p = new Promise(function(resolve, reject) {
    throw "Sorry";
}).
then((data) => console.log(data), (data) => data);
The problem is caused by the expression this.status === "200" (in line 2), as status doesn't return a string; but instead it returns a number. See AJAX States for more info.
What will the code below log?
var p = new Promise(function(resolve, reject) {
    resolve("OK");
});

var p2 = p.then(function(data) {
    return data;
});

var p3 = p.then(function(data) {
    return data;
});

console.log(p2 === p3);
The reason as to why choice (A) is the answer here, is detailed in the AJAX States chapter where we discuss how it works internally.
What will the code below log?
var p = new Promise(function(resolve, reject) {
    resolve("OK");
});

var p2 = p.then(function(data) {
    return new Promise(function(resolve, reject) {
        resolve(`data is ${data}`);
    });
});

p2.then(function(data) {
    console.log(data);
});
The reason as to why choice (B) is the answer here, is detailed in the AJAX States chapter where we discuss how it works internally.