Past-paper question · 2018 May-June · Paper 32 · Q4(a)

Question 4(a) 2018 · May-June · Paper 32 · 5 marks

Original past-paper question for 4(A)
Original past-paper question for 4(A)
Reveal official mark-scheme answer Official mark-scheme answer for 4(A)

Official answer for Question 4

Part (a)

✓
Five from:

Question 5

✓
Variables X and ‘displayresult’ are declared
✓
...and cleared before use by loop
✓
Loop starts with X at 1
✓
X is incremented by 3 each time it loops
✓
Continues until X reaches 10/while X is less than 10
✓
Displays result as 1, 4, 7
✓
With carriage return between each/on separate lines/underneath each other.
✓
9626/32
✓
Cambridge International AS/A Level – Mark Scheme
✓
May/June 2018
✓
PUBLISHED
✓
Question
✓
Answer
✓
Marks

Mark scheme 9626_s18_ms_32.pdf →

Show text version of question

Question 4

Part (a)

Question 4

‘Loops’ are used in JavaScript to execute a block of code several times.

The following code shows a ‘for’ loop and the code for displaying the result.

<p id="Number"></p>

<script> //JavaScript code follows var displayresult = ""; var X;

for (X = 1; X < 10; X += 3) { displayresult += X + "<br>"; } //the following line displays the contents of ‘displayresult’ on the webpage document.getElementById("Number").innerHTML = displayresult; </script>

Part (a)

Describe what each statement in the ‘for’ loop does and the results that are output when the

code is executed.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[5]

Question 7

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_s18_qp_32.pdf

Keep practising this topic