Programming for the web – A Level Information Technology (9626)

66 questions · page 3 of 5 · Clear filters

0 / 0Answer a question to start your score.
Quick quiz (10)Saved 0
Advertisement
31
9626/32/F/M/22 · Question 7Feb/March 2022Paper 326 marks
Loading question…
Question text

7
The prompt() method is used in JavaScript to provide a popup dialog box for users to interact
with web pages.
(a) Explain how the result of the user interaction from prompt() is used by a programmer to
collect the input from a user.
…
…
…
…
…
…
…
…
…
…
… [4]
(b) Explain two limitations of using the prompt() method of user interaction.
1 …
…
…
2 …
…
…
[2]

32
9626/31/O/N/21 · Question 2Oct/Nov 2021Paper 318 marks
Loading question…
Question text

2
QR codes are two-dimensional bar codes (matrix bar codes) representing information about items
to which they are attached. An example of a QR code is shown:
(a) Describe the functional elements of a QR code.
…
…
…
…
…
…
…
…
…
…
… [5]
(b) Explain why damaged QR codes may still be read while damaged one-dimensional bar codes
often cannot be read.
…
…
…
…
…
…
… [3]

33
9626/31/O/N/21 · Question 10Oct/Nov 2021Paper 316 marks
Loading question…
Question text

10 JavaScript is an interpreted language that can be used on web pages. Runtime errors, called
exceptions, can occur during the execution of JavaScript code.
Explain how exceptions can be handled during the execution of JavaScript code.
…
…
…
…
…
…
…
…
…
…
…
…
…
… [6]

Advertisement
34
9626/32/O/N/21 · Question 3Oct/Nov 2021Paper 326 marks
Loading question…
Question text

3
JavaScript is a programming language used within HTML on web pages.
Explain why it is considered good practice when coding in JavaScript to:
(a) place all declarations at the start of each script or function
…
…
…
…
…
… [2]
(b) initialise variables when first declared
…
…
…
…
…
… [2]
(c) avoid using eval() to run a string as code
…
…
… [1]
(d) always declare local variables.
…
…
… [1]

35
9626/31/M/J/21 · Question 10May/June 2021Paper 316 marks
Loading question…
Question text

10 Jasmine is using JavaScript on her web pages to provide interactivity. She has encountered some
runtime errors during the testing of her JavaScript code.
She has written some code including window.onerror = function (msg, url, line)
The onerror() event handler will trap errors.
Describe how this can help Jasmine locate the mistakes in the rest of her code.
…
…
…
…
…
…
…
…
…
…
…
…
…
… [6]

36
9626/32/F/M/21 · Question 3Feb/March 2021Paper 329 marks
Loading question…
Question text

3
QR codes are two-dimensional barcodes (matrix barcodes) which store information. The codes
can be used to contain links to a website.
(a) Describe three other uses of information that can be contained in QR codes.
…
…
…
…
…
…
… [3]
(b) QR codes can often be found on products in supermarkets.
Evaluate, by weighing up the advantages and disadvantages, the use of QR codes for holding
information about the products.
…
…
…
…
…
…
…
…
…
…
…
…
…
… [6]

37
9626/32/O/N/20 · Question 1Oct/Nov 2020Paper 329 marks
Loading question…
Question text

1
(a) Explain the meanings of these terms when referring to JavaScript objects.
(i)
string
…
…
… [1]
(ii)
global
…
…
… [1]
(iii)
regular expression
…
…
… [1]
(iv)
operator
…
…
… [1]
(v)
statement
…
…
… [1]
(b) Describe, in detail, the use of console.log() in JavaScript to output data for display.
…
…
…
…
…
…
…
…
…
… [4]

38
9626/33/O/N/20 · Question 5Oct/Nov 2020Paper 337 marks
Loading question…
Question text

5
(a) The JavaScript code shown in Fig. 5.1 adds together 12 and 6 to produce the result 18. Line
numbers are shown only for reference purposes.
1
<html>
2
<head>
3
</head>
4
<body>
5
<br>
6
<h1>A Web Page</h1>
7
<p>A Paragraph</p>
8
<script>
9
var x, y;
10
x=12;
11
y=6;
12
window.alert(x + y);
13
</script>
14
</body>
15
</html>
Fig. 5.1
Describe how the script operates to display the result on the screen.
…
…
…
…
…
…
…
…
…
…
…
…
…
… [6]
JavaScript uses the display capabilities of web browsers’ windows to output the results of its
scripts.
(b) Explain why JavaScript uses a browser’s windows to display results of running scripts.
…
…
…
… [1]

Advertisement
39
9626/31/M/J/20 · Question 8May/June 2020Paper 314 marks
Loading question…
Question text

8
Nigel is creating a website which uses JavaScript. He uses scripts to manipulate text held in
HTML elements so that it can be displayed on his pages.
(a) Explain what is meant by an ‘HTML element’.
…
…
…
…
…
… [2]
Nigel uses this code to manipulate the text on his page. The line numbers are shown only for
reference purposes.
1
2
<html>
3
<body>
4
5
<h2>Nigel uses this JavaScript to change HTML</h2>
6
7
<p id="a1">Nigel's original text was here</p>
8
9
<script>
10
document.getElementById("a1").innerHTML = "Nigel changed this!";
11
</script>
12
13
<p>The paragraph above was changed by Nigel's script.</p>
14
15
</body>
16
</html>
(b) Explain, in detail, how this JavaScript would change what is displayed on the web page.
…
…
…
…
…
… [2]

40
9626/32/M/J/20 · Question 10May/June 2020Paper 328 marks
Loading question…
Question text

10 A teacher is creating a web page for his students to find out their result, Merit, Pass or Fail, by
entering their test score. The teacher has chosen to use the JavaScript switch function to examine
the test score entered by the student and report the result on the web page.
The code for the web page is shown in Fig. 10.1. The lines are numbered only for your convenience.
1
2
<html>
3
<body>
4
5
<input id="myTscore" type="number" value=0>
6
<button onclick="tscorelookup()">Check Your Result by entering your
test score 0-100 </button>
7
<p id="myresult"></p>
8
9
<script>
10
function tscorelookup(){
11
var report;
12
var result = document.getElementById("myTscore").value;
13
14
switch(true){
15
case result < 0:
16
report = "You cannot score a mark below 0";
17
break;
18
case result > 100:
19
report = "You cannot score a mark above 100";
20
break;
21
case result >= 40:
22
report = "Your result is a Merit";
23
break;
24
case result >= 20:
25
report = "Your result is a Pass";
26
break;
27
case result < 20:
28
report = "Your result is a Fail";
29
break;
30
default:
31
report = "Please enter a valid mark";
32
}
33
document.getElementById("myresult").innerHTML = report;
34
}
35
</script>
36
37
</body>
38
</html>
Fig. 10.1
The HTML code in lines 5 to 7 collects the test score entered by the student and, when the button
is clicked, makes the test score available to the JavaScript code that starts at line 9.
Describe, in detail, how the JavaScript code works to handle a test score of 18.
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…

41
9626/32/F/M/20 · Question 3Feb/March 2020Paper 3212 marks
Loading question…
Question text

3
(a) Describe the characteristics of incremental prototyping.
…
…
…
…
…
…
…
…
…
… [4]
(b) Discuss the advantages and disadvantages of incremental prototyping.
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
...

42
9626/32/F/M/20 · Question 4Feb/March 2020Paper 326 marks
Loading question…
Question text

4
Describe how 3D printing would be used when creating objects for use in space exploration.
…
…
…
…
…
…
…
…
…
…
…
…
…
… [6]

43
9626/32/F/M/20 · Question 9Feb/March 2020Paper 3210 marks
Loading question…
Question text

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.
1
function myFunction() {
2
var statement;
3
var age = document.getElementById("age").value;
4
if (age < 10) {
5
statement = "You are not old enough to go to this school";
6
} else if (age < 18) {
7
statement = "You can go to this school";
8
} else {
9
statement = "You are too old to go to this school";
10
}
Fig. 9.1
(a) Explain, with reference to the code in the function, how the ‘if else’ and ‘else if’ statements
operate to provide the appropriate statement when an age is entered into the web page and
collected by the HTML code.
…
…
…
…
…
…
…
…
…
…
…
…
…
… [6]
(b) The code could have been written using the ‘switch’ function, e.g. lines 4 to 7 could have
been:
4
switch(true) {
5
case age < 10:
6
statement = "You are not old enough to go to this school";
7
break;
with additional lines for the other conditions.
Explain the drawbacks of using the ‘switch’ function.
…
…
…
…

Advertisement
44
9626/31/O/N/19 · Question 19Oct/Nov 2019Paper 316 marks
Loading question…
Question text

19
Explain, with reference to the code shown, how the JavaScript collects the dimensions of the
rectangle, calculates the area and displays the area on-screen.
The lines of the code are numbered only for your convenience when referring to the code.
…
…
…
…
…
…
…
…
…
…
…
…
…
… [6]
Permission to reproduce items where third-party owned material protected by copyright is included has been sought and cleared where possible. Every
publisher will be pleased to make amends at the earliest possible opportunity.
To avoid the issue of disclosure of answer-related information to candidates, all copyright acknowledgements are reproduced online in the Cambridge
Assessment International Education Copyright Acknowledgements Booklet. This is produced for each series of examinations and is freely available to download
at www.cambridgeinternational.org after the live examination series.
Cambridge Assessment International Education is part of the Cambridge Assessment Group. Cambridge Assessment is the brand name of the University of

45
9626/32/O/N/19 · Question 3Oct/Nov 2019Paper 323 marks
Loading question…
Question text

3
JavaScript uses strings to store data.
This script is intended to display the contents of three variables on a web page.
Line numbers are provided only for your convenience when referring to the code.
1
<html>
2
<body>
3
4
<p id="names"> </p>
5
<script>
6
var statementtxt1 = "It's only me, 'Hardeep'";
7
var statementtxt2 = "His name is "Peter"";
8
var statementtxt3 = "We call her Jasmine";
9
document.getElementById( 'names' ).innerHTML = statementtxt1 + "<br>"
+ statementtxt2 + "<br>" + statementtxt3;
10 </script>
11 </body>
12 </html>
Explain, giving reasons, why no output is produced when this JavaScript is executed by a web
browser as part of a web page.
…
…
…
…
…
…
…
… [3]

Advertisement