Past-paper question · 2020 February-March · Paper 32 · Q9

Question 9 2020 · February-March · Paper 32 · 0 marks

Original past-paper question for 9
Reveal official mark-scheme answer

The answer for this question is in the official mark scheme: open the mark scheme.

Mark scheme 9626_m20_ms_32.pdf →

Show text version of question

Question 9

In JavaScript, conditional statements can be used to carry out specific actions based upon different conditions. The value of the variable ‘age’ is entered into a web page and collected by the HTML code of the page. The function in Fig. 9.1 uses the ‘if else’ and ‘else if’ conditional statements to test the value of the variable ‘age’. Line numbers are shown only for your convenience when referring to the code.

Question 1

function myFunction() {

Question 2

var statement;

Question 3

var age = document.getElementById("age").value;

Question 4

if (age < 10) {

Question 5

statement = "You are not old enough to go to this school";

Question 6

} else if (age < 18) {

Question 7

statement = "You can go to this school";

Question 8

} else {

Question 9

statement = "You are too old to go to this school";

Topic relevance

Why this question appears here

98% assigned-topic match · Programming for the web

Topic-match percentages estimate how closely each question fits the selected syllabus topic. They are a guide for choosing stricter or broader practice.

Permanent source page: Educate A Change · From 9626_m20_qp_32.pdf

Keep practising this topic