wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

JavaScript Basics Quiz

Total questions: 15

Worksheet time: 8mins

Name
Class
Date
1.

What does the readLine() function do in JavaScript?

a)

Reads a number from the user

b)

Reads a string from the user

c)

Displays text on the screen

d)

Runs a loop

2.

Which function allows reading a number with decimals?

a)

readInt()

b)

readFloat()

c)

readString()

d)

readDecimal()

3.

Which function is used to display text in JavaScript?

a)

print()

b)

show()

c)

println()

d)

display()

4.

What is a variable?

a)

A fixed value

b)

A container that holds data

c)

A programming error

d)

A type of function

5.

Which line correctly declares and initializes a variable?

a)

age = 15;

b)

var age = 15;

c)

variable age 15;

d)

int age = 15;

6.

What type of data does a Boolean variable hold?

a)

Text

b)

Numbers

c)

True or False

d)

Characters

7.

What happens if you forget quotation marks around a string?

a)

The program crashes

b)

It runs normally

c)

It prints numbers only

d)

It becomes a Boolean

8.

Which is the correct syntax for combining variables and text?

a)

println("My age is", age);

b)

println("My age is " + age);

c)

print(age "My age is");

d)

println("age " "My is");

9.

What symbol is used to join text and variables in JavaScript?

a)

*

b)

&

c)

+

d)

=

10.

What does the following code print? var color = "Blue"; println("My favorite color is " + color);

a)

Blue

b)

My favorite color is Blue

c)

My favorite color is

d)

color = Blue

11.

What does the readInt() function do?

a)

Reads text from the user

b)

Reads a decimal number

c)

Reads a whole number

d)

Prints a number to the screen

12.

What type of number does readFloat() return?

a)

Integer

b)

Decimal

c)

String

d)

Boolean

13.

Which of the following correctly declares a variable in JavaScript?

a)

let = name "John";

b)

var name = "John";

c)

var = name "John";

d)

name var = "John";

14.

What is the purpose of a variable?

a)

To store data

b)

To display output

c)

To delete data

d)

To repeat commands

15.

Which statement is true about variables?

a)

They can only store numbers

b)

They cannot change once set

c)

They can hold different types of data

d)

They are only used in math