JavaScript Simplified / Chapter 105 Exercises

  • Index of exercises
  • Email me

1

2

3

4

5

6

7

8

9

10

Congratulations. You've aced all the exercises for this chapter.


To practice on your own, or to check code you believe shouldn't have been scored as incorrect, go to CodePen.


Are you ready to rate JavaScript Simplified? on Amazon?


Rate it on Amazon.

0,1,2,3,4,5,6,7,8,9

0

0

0

0

Fill in the blank. const prom = _________(function(resolve, reject) { new Promise newPromise
Fill in the blank. Make up the name of the promise. __________ = new Promise(function(resolve, reject) { const prom const[a-z_$][a-zA-Z0-9_$]*
Fill in the blank. Make up the name of the promise. _____________________(function(resolve, reject) { const prom = new Promise const[a-z_$][a-zA-Z0-9_$]*=newPromise
Fill in the blank. const prom = new Promise(__________________) { function(resolve, reject function\(resolve,reject
Code the first line of a promise. Make up the name of the promise. const prom = new Promise(function(resolve, reject) { const[a-z_$][a-zA-Z0-9_$]*=newPromise\(function\(resolve,reject\){
Fill in the blank. Make up the name of the message. const prom = new Promise(function(resolve, reject) {
  let pet = "cat";
  if (pet === "cat") {
    ________________________________
  } else {
    reject("Something is wrong");
  }
});
    resolve("All is well"); resolve\(•.*•\);
Fill in the blank. Make up the message. const prom = new Promise(function(resolve, reject) {
  let pet = "cat";
  if (pet === "cat") {
    resolve("All is well");
  } else {
    ___________________________________
  }
});
    reject("Something is wrong"); reject\(•.*•\);
Fill in the blanks. Make up the messages. const prom = new Promise(function(resolve, reject) {
  let pet = "cat";
  if (pet === "cat") {
    ______________
  _______
    __________________
  __
});
    resolve("All is well");
  } else {
    reject("Something is wrong");
  }
resolve\(•.*•\);[\r\n]}else{[\r\n]reject\(•.*•\);[\r\n]}
  1. Above my code, code the first line of the promise. The name of the promise is prom.
  2. Click the Result button (or, after revising, don't click, just wait).
  3. Wait a moment.
  4. If you've coded correctly, an alert will display the message.
  5. Dismiss the alert by clicking OK.
  6. For help with this code, see Chapter 105 in the book.
  1. Insert the rest of the promise. Your code is testing whether pet === "dog".
  2. Click the Result button (or, after revising, don't click, just wait).
  3. Wait a moment.
  4. If you've coded correctly, an alert will display the message.
  5. Dismiss the alert by clicking OK.
  6. For help with this code, see Chapter 105 in the book.