Completed tests
Login
Learning aids
Contact us
Login with Facebook
General tests
Programing skills
UK S3-S4
UK S2
Grade 3-4
Grade 4
JavaScript - Test 1
Programing skills - JavaScript - Math
1.
Between which HTML tags do we put the JavaScript?
<js>
<scripting>
<script>
<javascript>
2.
JavaScript and Java are the same.
True
False
3.
Where is the correct place to insert a JavaScript?
The <head> section.
Both the <head> section and the <body> section are correct.
None of above.
The <body> section.
4.
What is the correct syntax for including an external script called "sample1.js"?
<#include "sample1.js">
<script name="sample1.js">
<script href="sample1.js">
<script src="sample1.js">
5.
The external JavaScript file
must
contain the
<script>
tag.
False
True
6.
How to write "Hello World!" message in JavaScript?
msg("Hello World");
alertBox("Hello World");
alert("Hello World");
msgBox("Hello World");
7.
How to create a function in JavaScript?
function:MyFunction()
function = New MyFunction()
function MyFunction()
function = MyFunction()
8.
How to call a function named "myFunction"?
call myFunction()
call function myFunction()
myFunction()
9.
How can you write a comment in a JavaScript?
<!-- This is a comment. -->
// This is a comment.
' This is a comment.
10.
How to write an
IF
statement in JavaScript?
if (i == 2)
if i = 2
if i = 2 then
if i == 2 then
11.
How to execute some code if "i" is NOT equal to 2?
if i <> 2
if (i != 2)
if (i <> 2)
if i != 2 then
12.
How does a WHILE loop start?
while i = 1 to 7
while (i <= 7; i++)
while (i <= 7)
13.
How does a FOR loop start?
for i = 1 to 10
for (i <= 10; i++)
for (i = 0; i <= 10)
for (i = 0; i <= 10; i++)
14.
How to write a comment that has more than one line?
// This comment has
more than one line //
<!-- This comment has
more than one line -->
/* This comment has
more than one line */
15.
What is the correct way to write a JavaScript array?
var colors = 1 = ("yellow"), 2 = ("purple"), 3 = ("blue")
var colors = "yellow", "purple", "blue"
var colors = (1:"yellow", 2:"purple", 3:"blue")
var colors = ["yellow", "purple", "blue"]
16.
How to round the number 3.14, to the nearest integer?
Math.rnd(3.14)
rnd(3.14)
Math.round(3.14)
round(3.14)
17.
How to find which number has the highest value (x and y)?
ceil(x, y)
Math.max(x, y)
Math.ceil(x, y)
top(x, y)
18.
What is the correct JavaScript syntax for opening a new window?
myWindow = New window("http://www.w3schools.com");
myWindow = window.new("http://www.w3schools.com");
myWindow = window.open("http://www.w3schools.com");
19.
What is the correct JavaScript syntax to change the content of the HTML element below?
<p id="demo">This is a demo text.</p>
$demo.innerHTML = "Hello World!";
document.getElementByName("p").innerHTML = "Hello World!";
document.getElement("p").innerHTML = "Hello World!";
document.getElementById("demo").innerHTML = "Hello World!";
#demo.text = "Hello World!";
20.
How to detect the client's browser name?
browser.name
client.navName
navigator.appName