Past-paper question · 2017 May-June · Paper 32 · Q9

Question 9 2017 · May-June · Paper 32 · 8 marks

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

Official answer for Question 9

✓
Six from:

Question 8

✓
Code is embedded within the body HTML code
✓
(global) variable (tableout) is declared/created/initialised
✓
The HTML table values are placed within the variable
✓
First/outer loop (on 4th line of JS code) executes 10 times«
✓
«to create 10 rows using global variable and HTML <tr> code/to create
✓
each row
✓
Second/inner loop is executed each time outer loop executes
✓
«to create 10 columns/cells
✓
First time inner loop executes, the cell contains 1*1=1...
✓
«second time inner loop executes, the cell contains 1*2=2
✓
«third time inner loop executes, the cell contains 1*3=3
✓
«up to cell that contains 1*10=10
✓
When inner loop reaches 10, first row of cells is complete«
✓
«next row is started with 2*1=2, 2*4 etc.
✓
«up to 2*10=20
✓
The process continues until outer loop reaches 10 and all 10 rows have
✓
been created and filled.

Mark scheme 9626_s17_ms_32.pdf →

Show text version of question

Question 9

JavaScript is a programming language used in webpages.

Fig. 2 shows a table created with JavaScript in a webpage.

1 2 3 4 5 6 7 8 9 10

Fig. 2

The code that created the table is shown below:

<html> <body> <script language="javascript"> var tableout; tableout = "<table border='1' width='300' cellspacing='0' cellpadding='3'>" for (b = 1; b <= 10; b++) { tableout = tableout + "<tr>"; for (g = 1; g <= 10; g++) { tableout = tableout + "<td>" + b * g + "</td>"; } tableout = tableout + "</tr>"; } tableout = tableout + "</table>"; document.write (tableout); </script> </body> </html>

Question 15

Explain how the loops in the code create the table.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

......................................................................................................................................................[8]

Question 16

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

Keep practising this topic