EduFlow
JavaScript Fundamentals

Checkpoint: JavaScript in the Browser

Five questions on this section. Answer all of them, then see your score and why each answer is right or wrong.

Question 1 of 5

A script in the <head> runs document.querySelector("#total").textContent = "$0.00"; and throws Cannot set properties of null. The id is spelled correctly. What fixes it?

Question 2 of 5

Pocket adds a click listener to each <li> when the page loads. Expenses added later do not respond to clicks. What is the best fix?

Question 3 of 5

After pressing Enter in Pocket’s form, the page reloads and the URL gains ?label=Tea. The handler is form.addEventListener("submit", () => { addExpense(); });. What is the cause?

Question 4 of 5

After a reload, localStorage.getItem("pocket") returns the text [object Object]. What went wrong when saving?

Question 5 of 5

The server answers this request with status 500 and an HTML error page. What happens?

JavaScript
async function load() {
  const res = await fetch("/api/expenses");
  return res.json();
}

5 questions unanswered