EduFlow
JavaScript Fundamentals

Checkpoint: Writing Real Programs

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

money.js contains export function formatMoney(cents) { … }. main.js contains import formatMoney from "./money.js";. What happens?

Question 2 of 5

What does this log?

JavaScript
class Store {
  #items = [];
  add(x) { this.#items.push(x); }
  get size() { return this.#items.length; }
}
const s = new Store();
s.add(1);
console.log(s.size, s.items);
Question 3 of 5

Your loader catches every error in this block. A bug inside render now goes unnoticed. What is the better structure?

JavaScript
try {
  const data = JSON.parse(text);
  render(data);
} catch {
  render([]);
}
Question 4 of 5

Pocket shows Total: $NaN after you add an expense. A breakpoint in totalCents shows the new expense has amount: undefined. Where do you look next?

Question 5 of 5

In Pocket, the delete handler calls button.closest("li").remove(). Deleted expenses come back when the filter changes. Why?

5 questions unanswered