These seven original questions follow one path: input box, processing, validation, keyboard use and the test log. They belong to web development without assessed-project substitution. Attempt each on paper first.
Questions
Question 1
Two boxes hold “25” and “5”. The code reads both values and shows a + b. What appears, and why?
Answer
The page shows 255. Box values are text, so + joins “25” and “5” into “255”. To get 30, convert each value with Number() before adding.
See tracing data from an HTML input to a displayed classroom result.
Question 2
Complete the trace for a box holding “80”, where the code is var m = Number(box.value); if (m >= 50) show "Pass".
Answer
- box.value is “80” (text).
- m = 80 (number).
- 80 >= 50 is true.
- The page shows “Pass”.
Question 3
What does an empty box give when read, and what does Number() turn it into? Why is that a problem for a mark checker?
Answer
An empty box gives the empty text “”, and Number(“”) is 0. A blank entry would then be treated as a mark of 0 and shown as a fail, when the user actually entered nothing. The page should check for an empty box first and ask for a mark.
Question 4
A page shows “Enter a mark from 0 to 100” using JavaScript, and the server has no check. A user sends the mark 250 without using the page. What happens, and what should change?
Answer
The browser check is skipped, and the server has no check, so 250 is accepted and stored. The server must validate the range itself. The browser message can stay, since it gives honest users quick feedback.
Question 5
Name one check that only the server can perform for a sign-up form, and explain why the browser cannot.
Answer
Checking whether a username is already taken. The list of existing usernames is stored on the server, so the browser has no way to compare against it. The lesson on client-side feedback versus server-side validation gives the full comparison.
Question 6
During a keyboard-only test, pressing Tab skips the Send button, which is built as a div with a click handler. Explain the fault and the fix.
Answer
A plain div is not an interactive control, so Tab does not reach it and Enter does not activate it. Replace it with a button element and keep the existing click handler. Then repeat the Tab and Enter steps. See testing a small page with keyboard-only interaction.
Question 7
Rewrite this test log row so it is reproducible: “Tried a big number. Got an error. Fixed it.”
Answer
One version:
- T4. Start: fresh page load, Mark box empty.
- Steps: type 250 in the Mark box, click Check once.
- Expected: message ‘Mark must be 0 to 100’.
- Actual: page showed Pass. Result: fail.
- Change: added a check that rejects marks above 100.
- Re-test actual: message shown. Result: pass.
It fixes the start state, the input, the steps, the expected and actual results, and the change. Compare it with documenting student-authored changes with a reproducible test log.
If you got these wrong
- Questions 1 to 3: read the tracing lesson linked under question 1.
- Questions 4 and 5: read the validation lesson linked under question 5.
- Question 6: read the keyboard lesson linked under question 6.
- Question 7: read the test log lesson linked under question 7.
To go through your answers with a teacher, see online one-to-one Computer Science tuition.