Programming for the web – A Level Information Technology (9626)
Question text
1
JavaScript can manipulate and store strings in variables.
(a) Define the term string as used in JavaScript.
…
…
… [1]
(b) Describe how a string can be created in JavaScript.
…
…
… [1]
(c) A variable text1 is used to store Cambridge and a variable text2 is used to store
International Examinations in a block of JavaScript code.
(i)
Describe how the two strings can be joined together (concatenated) as Cambridge
International Examinations and stored in a new variable called text3 in a
JavaScript statement.
…
…
…
…
…
… [2]
(ii)
Describe one method by which the word Examinations can be extracted from text3
for use in another variable.
…
…
…
…
…
… [2]
ĬÕú¾Ġ´íÈõÏĪÅĊßû¸þ×
Question text
1
JavaScript uses loops to execute a block of code using Iterative methods.
(a) Describe what is meant by an Iterative method.
…
…
…
…
…
… [2]
(b) Explain how a do/while loop differs from a while loop.
…
…
…
…
…
… [2]
(c) Explain why a while loop might be used instead of a for loop in JavaScript code.
…
…
… [1]
Question text
2
Web pages can be made more attractive and easier to read by using colours. All major web
browsers support the use of HSL to specify the colours used in web pages.
Explain how HSL is used to specify colours.
…
…
…
…
…
…
…
…
…
…
…
…
…
… [6]
Question text
4
JavaScript code has been developed for an interactive website. White box testing is carried out by
the developers.
(a) Describe how white box testing is used to test the code.
…
…
…
…
…
…
…
…
…
…
…
…
…
… [6]
(b) Describe one way that JavaScript code can add interactivity to a web page.
…
…
…
… [1]
(c) HTML events occur when users interact with a web page.
Describe how JavaScript code can be made to react to an HTML event.
…
…
…
…
…
…
…
Question text
2
Explain why break statements, functions and comments are used in JavaScript code.
(a) Break statements
…
…
…
…
…
… [2]
(b) Functions
…
…
…
…
…
… [2]
(c) Comments
…
…
…
…
…
… [2]
Question text
2
A company holds special events for selected customers on various dates throughout the year.
Source documents of customer lists are used to create customised invitations by mail merge.
(a) Explain why source documents are proof read manually to try to ensure that the final versions
are accurate and error-free.
…
…
…
…
…
…
…
… [3]
(b) Explain how a merge field can be used to prompt for and insert the date of the special event
in the invitations when they are produced.
…
…
…
…
…
…
…
…
…
… [4]
Question text
7
(a) Describe each of the following terms when referring to JavaScript statements.
(i)
operand
…
…
… [1]
(ii)
operator precedence
…
…
… [1]
(iii)
assignment operator
…
…
… [1]
(iv)
literals
…
…
… [1]
(b) JavaScript has its own group of reserved keywords which cannot be used as names for
variables, labels or functions.
Describe one other group of reserved words that should not be used when writing JavaScript
code for use on web pages.
…
…
… [1]
Question text
6
Loops in JavaScript repeatedly execute blocks of code.
(a) Describe how a for loop works in JavaScript code.
…
…
…
…
…
…
…
…
…
… [4]
(b) Contrast the use of while and do while loops in JavaScript code.
…
…
…
…
…
… [2]
Question text
7
In JavaScript, an object is defined as a collection of properties which can be amended or deleted.
(a) Describe how an object may be given a new property.
…
…
…
… [1]
(b) Describe how the properties of an object in JavaScript can be displayed using a loop.
…
…
…
…
…
…
…
…
…
… [4]
Question text
1
JavaScript can be used in a web-based form to test whether a number entered by a user matches
a certain condition and to select and output an appropriate message.
(a) Explain how if...else statements are used to do this.
…
…
…
…
…
…
…
…
…
… [4]
(b) The ternary operator could be used instead of if...else.
Explain why the ternary operator could be used to do this.
…
…
…
…
…
…
…
… [3]
Question text
8
JavaScript code can be written to perform different actions depending on different conditions.
(a) Describe the use of the switch operator, such as switch(name), in JavaScript code to select
different actions.
…
…
…
…
…
…
…
…
…
… [4]
(b) Describe the use of logical operators in conditional statements in JavaScript code.
…
…
…
…
…
…
…
…
…
…
…
…
…
… [6]
Question text
9
A programmer is writing some JavaScript code to display this text on a web page:
This is “Cambridge International IT 9626 Paper 3”
The programmer uses strings in the code.
(a) Describe the purpose of strings in JavaScript.
…
…
… [1]
(b) The programmer’s first attempt at the HTML and JavaScript code is shown in Fig. 9.1. Line
numbers are shown only for your use when referring to the code.
1
<!DOCTYPE html>
2
<html>
3
<body>
4
5
<h2>This is "Cambridge Assessment International Education"</h2>
6
7
<p id="string"></p>
8
9
<script>
10
var x = "This is "Cambridge International IT 9626 Paper 3"";
11
document.getElementById("string").innerHTML = x;
12
</script>
13
14
</body>
15
</html>
Fig. 9.1
When run in a web browser the HTML code outputs the heading in line 5 on the page. The browser
executes the JavaScript code shown in lines 9 to 12.
The expected output of the code on the web page is shown in Fig. 9.2 but the actual output is
shown in Fig. 9.3.
Fig. 9.2
Fig. 9.3
Explain why the error in line 10 prevents the JavaScript code from outputting:
This is “Cambridge International IT 9626 Paper 3”
…
…
…
…
…
…
…
…
…
…
… [4]
(c) JavaScript programmers often wish to control when sections of their code are executed.
Compare the use of setTimeout() and setInterval() for delaying the execution of
JavaScript code.
…
…
…
…
Question text
1
Data can be at risk of being lost from computer systems.
(a) Describe the ways that data can be lost from computer systems.
…
…
…
…
…
…
…
…
…
…
… [5]
(b) Backups are used to minimise the risk of data loss. Backup strategies are created for
technicians to ensure that data can be recovered in the event of a disaster occurring.
Describe three instructions to the technicians that should be included in a backup strategy.
1 …
…
…
2 …
…
…
3 …
…
…
[3]
Question text
8
JavaScript code can use comparison operators.
Explain how each of the following comparison operators works in JavaScript when comparing the
number 1 with the text “1”.
(a) the == operator
…
…
…
…
… [2]
(b) the !== operator
…
…
…
…
… [2]
Question text
4
The confirm() method is used in JavaScript to create and provide dialog boxes for users to
interact with web pages.
(a) Describe the purpose of two elements of the dialog box that appears when confirm() is
used.
…
…
…
…
… [2]
(b) Explain why the use of confirm() may cause problems on web pages.
…
…
…
…
…
…
…
… [3]
(c) Explain how the result of the user interaction from confirm() is reported back to the
JavaScript code for use in the remaining code.
…
…
…
…
… [3]