☰ Year plan · Communication Technology

Dynamic pages, a quiz and a game

Week 14 · Chapter 13 AI Programming (2): dynamic web pages, presenting your site, a quiz app, a block-breaker game and reviewing what you built · 3 lessons
Answers are for parents and teachers.
1
The counter handler adds 3 instead of 1 (count = count + 3). What does the page show after 4 clicks?
2
A quiz has 4 questions and the pupil gets 3 right. Write what the page shows at the end.
3
Trace the ball for four steps from x = 90 with dx = 5 (the same rules as in the lesson). Write x and dx after each step.
JavaScript
1let x = 80;
2let dx = 5;
3function step() {
4  x = x + dx;
5  if (x >= 100 || x <= 0) {
6    dx = -dx;
7  }
8}
4
This handler does not show the name. Find the mistake and write the fixed line.
JavaScript
1const box = document.getElementById("name");
2const out = document.getElementById("out");
3document.getElementById("hello").onclick = () => {
4  out.textContent = "Hello " + box.text;
5};
5
Write the debugging routine in four steps, and say which one you do first.