wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

JavaScript Basic

Total questions: 16

Worksheet time: 8mins

Name
Class
Date
1.
Indicates the beginning  and the end of a JavaScript section.
a)
<html> </html>
b)
<style> </style>
c)
<article> </article>
d)
<script> </script>
2.
A JavaScript file has an extension name of
a)
.jscp
b)
.js
c)
.css
d)
.Jp
3.
Which keyword do we need to define a function?
a)
function
b)
method
c)
onclick
d)
functionName()
4.
What type of variable is
var typeOfApples="Fuji";
a)
Int
b)
Float
c)
Boolean
d)
String
5.

How can a developer show a pop-up message to the user?

a)

alert

b)

prompt

c)

console.log

d)

<p> tag

6.
Which message will the user see?
a)
"Hello user"
b)
No message
c)
"Goodbye user"
d)
"message + user"
7.

What attribute/value do we use to make a button execute JavaScript when clicked?

a)

onclick="doSomething;"

b)

on-click="doSomething;"

c)

onclick="doSomething();"

d)

onclick=doSomething();

8.
How do I declare a new variable?
a)
var newVariable = 5;
b)
Variable int = new Variable();
c)
var 5 = myVariable;
d)
int var = 5;
9.
What is CSS used for?
a)
styling web pages
b)
formatting script correctly
c)
client side scripting
d)
server side scripting
10.
How do I change the size of an image?
a)
width / height
b)
scale
c)
size
d)
shrink
11.

What is the correct syntax for referring to an external JavaScript script?

a)

<script src="myscript.js"></script>

b)

<script href="myscript.js"></script>

c)

<js href="myscript.js"></js>

d)

<js src="myscript.js"></js>

12.

We cannot Place JS Code in the body tag . Say true/false.

a)

True

b)

False.

13.

What will be logged to the console here?
console.log(5 + 7 + "hello" +5 + 12);

a)

57hello512

b)

12hello17

c)

12hello512

d)

57hello17

14.

How do you write "Hello World" in an alert box?

a)

msg("Hello World");

b)

alertBox("Hello World");

c)

alert("Hello World");

d)

msgBox("Hello World");

15.

JavaScript : What is the alert display for text3 ?

a)

John Doe

b)

JohnDoe

c)

"John" " " "Doe"

d)

"JohnDoe"

16.

What are variables? Choose two from the answers.

a)

container for storing data

b)

storing data values

c)

A cupboard

d)

hold a water in it