wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

JavaScript Basics Quiz

Total questions: 10

Worksheet time: 5mins

Name
Class
Date
1.

What does the println() function do in JavaScript?

a)

Moves Karel forward

b)

Prints text or output to the console

c)

Creates a new variable

d)

Clears the screen

2.

What will this code output? println("Hello"); println("World");

a)

Hello World (on one line)

b)

Hello (on one line) and World (on next line)

c)

HelloWorld

d)

Error

3.

What happens if you forget the quotation marks in: println(Hello);

a)

It prints Hello

b)

It prints nothing

c)

It causes an error

d)

It repeats forever

4.

What is the correct way to create a variable in JavaScript?

a)

var = name "Jeremy";

b)

var name = "Jeremy";

c)

variable name = "Jeremy";

d)

name var = "Jeremy";

5.

What is a variable?

a)

A fixed number that never changes

b)

A command that prints text

c)

A box that holds a value

d)

A loop that repeats a task

6.

Which of the following is a valid variable name?

a)

8ball

b)

my var

c)

numApples

d)

VarName

7.

What type of variable would store the value "Hello"?

a)

Number

b)

Boolean

c)

String

d)

Float

8.

What is the value of numApples after this code runs? var numApples = 5; numApples = 0;

a)

5

b)

0

c)

undefined

d)

error

9.

Why is it important to use descriptive variable names?

a)

Makes code easier to read and understand

b)

Makes the program run faster

c)

Helps println work correctly

d)

Required by CodeHS

10.

What do both Karel and JavaScript programs have in common?

a)

They use println()

b)

They both use commands inside a function

c)

They both move Karel

d)

They don’t need syntax