wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

javascript Quiz 1

Total questions: 10

Worksheet time: 5mins

Name
Class
Date
1.

Which of the following will decrease the value of x?

a)

x--;

b)

x-1;

c)

x=x;

d)

x=-x;

2.

What is printed to the screen if the user enters ‘5’ when the following program is run?


var userNum = readInt("Enter your favorite number: ");

var calculatedNum = (userNum * userNum) + userNum;

println(calculatedNum);

a)

5

b)

30

c)

25

d)

50

3.

How many choices are possible when using a single if-else statement?

a)

1

b)

2

c)

3

d)

4

4.

Why do programmers use variables?

a)

Because they are lazy and don’t want to write out equations every time

b)

It allows the programmer to reuse multiple lines of code

c)

They are a way to document functions

d)

To store values to easily reuse later and make code easier to read and understand

5.
A JavaScript file has an extension name of
a)
.jscp
b)
.js
c)
.css
d)
.Jp
6.

What type of variable is apple?

var apple = " Fuji "

a)

string

b)

Boolean

c)

array

d)

number

7.

What kind of statement is an If statement?

a)

comparison statement

b)

anecdotal statement

c)

conditional statement

d)

looping statement

8.

Which of these will increase the value of the variable X?

a)

increment (x)

b)

x++;

c)

x=x;

d)

x+1;

9.

Inside which HTML element do we put the JavaScript?

a)

<script>

b)

<javaScript>

c)

<js>

d)

<scripting>

10.

The output of this code

a)

10

b)

5

c)

Null

d)

undefined