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?
<scripting>
<javascript>
<js>
<script>
2.
JavaScript and Java are the same.
False
True
3.
Where is the correct place to insert a JavaScript?
The <head> section.
The <body> section.
None of above.
Both the <head> section and the <body> section are correct.
4.
What is the correct syntax for including an external script called "sample1.js"?
<script src="sample1.js">
<script href="sample1.js">
<script name="sample1.js">
<#include "sample1.js">
5.
The external JavaScript file
must
contain the
<script>
tag.
True
False
6.
How to write "Hello World!" message in JavaScript?
msgBox("Hello World");
msg("Hello World");
alert("Hello World");
alertBox("Hello World");
7.
How to create a function in JavaScript?
function:MyFunction()
function = MyFunction()
function MyFunction()
function = New MyFunction()
8.
How to call a function named "myFunction"?
call function myFunction()
myFunction()
call 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 then
if (i <> 2)
12.
How does a WHILE loop start?
while (i <= 7)
while (i <= 7; i++)
while i = 1 to 7
13.
How does a FOR loop start?
for (i = 0; i <= 10)
for (i = 0; i <= 10; i++)
for i = 1 to 10
for (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 = ["yellow", "purple", "blue"]
var colors = "yellow", "purple", "blue"
var colors = 1 = ("yellow"), 2 = ("purple"), 3 = ("blue")
var colors = (1:"yellow", 2:"purple", 3:"blue")
16.
How to round the number 3.14, to the nearest integer?
rnd(3.14)
Math.round(3.14)
round(3.14)
Math.rnd(3.14)
17.
How to find which number has the highest value (x and y)?
Math.max(x, y)
ceil(x, y)
top(x, y)
Math.ceil(x, y)
18.
What is the correct JavaScript syntax for opening a new window?
myWindow = window.new("http://www.w3schools.com");
myWindow = window.open("http://www.w3schools.com");
myWindow = New window("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>
document.getElement("p").innerHTML = "Hello World!";
#demo.text = "Hello World!";
$demo.innerHTML = "Hello World!";
document.getElementById("demo").innerHTML = "Hello World!";
document.getElementByName("p").innerHTML = "Hello World!";
20.
How to detect the client's browser name?
browser.name
client.navName
navigator.appName