JavaScript Simplified / Chapter 104 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. let aRequest = new XMLHttpRequest();
aRequest.open("GET", "sample-text-file-80mg.txt");
aRequest.onload = ______________
  if (aRequest.status === 200) {
    document.querySelector("#place-to-put-it").textContent = aRequest.responseText;
  } else {
    document.querySelector("#place-to-put-it ").textContent = "Failed to load the text file";
  }
}; aRequest.send();
function() { function\(\){
Fill in the blank. let aRequest = new XMLHttpRequest();
aRequest.open("GET", "sample-text-file-80mg.txt");
______________________   if (aRequest.status === 200) {
    document.querySelector("#place-to-put-it").textContent = aRequest.responseText;
  } else {
    document.querySelector("#place-to-put-it ").textContent = "Failed to load the text file";
  }
}; aRequest.send();
aRequest.onload = function() { aRequest\.onload=function\(\){
Fill in the blank. let aRequest = new XMLHttpRequest();
aRequest.open("GET", "sample-text-file-80mg.txt");
aRequest.onload = function() {
  if (aRequest.status === ______
    document.querySelector("#place-to-put-it").textContent = aRequest.responseText;
  } else {
    document.querySelector("#place-to-put-it ").textContent = "Failed to load the text file";
  }
}; aRequest.send();
200) { 200\){
Fill in the blank. let aRequest = new XMLHttpRequest();
aRequest.open("GET", "sample-text-file-80mg.txt");
aRequest.onload = function() {
  if (_____________200) {
    document.querySelector("#place-to-put-it").textContent = aRequest.responseText;
  } else {
    document.querySelector("#place-to-put-it ").textContent = "Failed to load the text file";
  }
};
aRequest.send();
aRequest.status === aRequest\.status===
Fill in the blank. let aRequest = new XMLHttpRequest();
aRequest.open("GET", "sample-text-file-80mg.txt");
aRequest.onload = function() {
_________________________________________
    document.querySelector("#place-to-put-it").textContent = aRequest.responseText;
  } else {
    document.querySelector("#place-to-put-it ").textContent = "Failed to load the text file";
  }
};
aRequest.send();
  if (aRequest.status === 200) { if\(aRequest\.status===200\){
Fill in the blank. let aRequest = new XMLHttpRequest();
aRequest.open("GET", "sample-text-file-80mg.txt");
aRequest.onload = function() {
  if (aRequest.status === 200) {
    document.querySelector("#place-to-put-it").textContent = __________________
  } else {
    document.querySelector("#place-to-put-it ").textContent = "Failed to load the text file";
  }
};
aRequest.send();
aRequest.responseText; aRequest\.responseText;
Fill in the blank. Make up the error message text. let aRequest = new XMLHttpRequest();
aRequest.open("GET", "sample-text-file-80mg.txt");
aRequest.onload = function() {
  if (aRequest.status === 200) {
    document.querySelector("#place-to-put-it").textContent = aRequest.responseText;
  } else {
____________________________________________________________________
  }
};
aRequest.send();
    document.querySelector("#place-to-put-it ").textContent = "Failed to load the text file"; document\.querySelector\(•#place-to-put-it•\)\.textContent=•.*•;
Fill in the blank. Make up the paragraph ID to copy the .txt file or error message into. Make up the error message text. let aRequest = new XMLHttpRequest();
aRequest.open("GET", "sample-text-file-80mg.txt");
______________________________
  ______________________________
    _____________________________________________________
  _____
    ________________________________________________
  ___
__
aRequest.send();
aRequest.onload = function() {
  if (aRequest.status === 200) {
    document.querySelector("#place-to-put-it").textContent = aRequest.responseText;
  } else {
    document.querySelector("#place-to-put-it ").textContent = "Failed to load the text file";
  }
};
aRequest\.onload=function\(\){[\r\n]if\(aRequest\.status===200\){[\r\n]document\.querySelector\(•(.*)•\)\.textContent=aRequest\.responseText;[\r\n]}else{[\r\n]document\.querySelector\(•\1•\)\.textContent=•.*•;[\r\n]}[\r\n]};
  1. Insert the body of the anonymous function into the code. The paragraph ID to copy the .txt file or error message into is "p1".
  2. Click the Result button (or, after revising, don't click, just wait).
  3. Wait a moment.
  4. If you've coded correctly, the error message will display in the Result panel
  5. For help with this code, see Chapter 104 in the book.
  1. Insert the anonymous function into the code. The paragraph ID to copy the .txt file or error message into is "p1".
  2. Click the Result button (or, after revising, don't click, just wait).
  3. Wait a moment.
  4. If you've coded correctly, the error message will display in the Result panel
  5. For help with this code, see Chapter 104 in the book.