Académique Documents
Professionnel Documents
Culture Documents
[2 marks]
BT (knowledge / comprehension)
Answer:
(4) Write a single line of JavaScript that will create an array called days containing the
strings "Monday", "Tuesday" and "Wednesday".
[1 mark]
BT (knowledge)
Answer:
var days = ["Monday", "Tuesday", "Wednesday"]
(5) Write a single line of JavaScript that will return the lowest values of two numeric
variables a and b
[1 mark]
BT (knowledge)
Answer:
Math.min(a,b);
(6) What would be output by the following JavaScript fragment?
<p id="output"></p>
<script>
var x;
document.getElementById("output").innerHTML = x + typeof(x);
</script>
[2 marks]
BT (knowledge/application)
Answer:
undefinedundefined
(7) What would be output by the following JavaScript code fragment?
<p id="output1"></p>
<p id="output2"></p>
<script>
var x;
document.getElementById("output1").innerHTML = 0 == false;
document.getElementById("output2").innerHTML = 0 === false;
</script>
BT (knowledge/application)
Answer:
true
false
[1 mark]
(8) In PHP how do you access information submitted from a form using the GET method
[1 mark]
BT (knowledge)
Answer:
It is available in the $_GET[] array
(9) Write a single line of PHP that will create an array called $days that contains the strings
"Monday", "Tuesday" and "Wednesday"
[1 mark]
BT (knowledge/application)
Answer:
$days = array("Monday","Tuesday","Wednesday")
(10)
Write PHP code that will loop through the @days array declared in question 12,
output the information as follows:
Red = 255:0:0
Green = 0:255:0
Blue = 0:0:255
[2 marks]
BT (application)
Answer:
foreach($colour as $col => $rgb) {
echo $col . " = " . $rgb;
echo "<br>";
}
(11)
Write PHP code that will output "Good morning" if the time is earlier than 12.00,
"Good afternoon" if it is between 12.00 and 18.00 and "Good evening" if it is after 18.00.
[2 marks]
BT (application)
Answer:
$time = date("H");
if ($time < "12") {
echo "Good morning";
} elseif ($time >= "12" && time < "18" ) {
echo "Good afternoon";
} else {
echo "Good evening";
}
}