Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

JavaScript

Total questions: 12

Worksheet time: 7mins

Name
Class
Date
1.

What other languages are typically used with JavaScript?

a)

Python

b)

Ruby

c)

HTML & CSS

d)

SQL

2.

What are the different ways to include JavaScript in your application? Choose all that apply.

a)

<script> alert('Hello'); </script>

b)

<link src='myjavascript.js'></link>

c)

<link href="myjavascript.js></link>

d)

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

3.

How would you declare a variable in JavaScript?

a)

var myName = "Sally"

b)

myName = "Sally"

c)

myName var = "Sally"

d)

var myName = Sally

4.

What is the difference between var and let in JavaScript?

a)

There are no differences, they are both the same.

b)

let is visible through blocks and accessed globally, var isn't.

c)

var is visible through blocks and accessed globally, let isn't.

d)

let is used more frequently, var isn't.

5.

When would you use the const declaration in JavaScript? Choose all that apply.

a)

When you're creating a variable.

b)

When a variable has a constant value that won't change.

c)

When creating a temporary variable.

6.

What would alert(6 + '2') show?

a)

8

b)

62

c)

6+'2'

d)

6'2'

7.

What would alert('6'-2) show:

a)

An error Message

b)

62

c)

'6'-2

d)

4

8.

Look at the following code:


let attendees = 568;

attendees++

document.write(attendees)


What will print to the browser?

a)

568

b)

570

c)

569

d)

An error message

9.

Look at the following code:


let total_price = 40;

total_price--

--total_price

document.write(total_price)


What will print to the browser?

a)

39

b)

40

c)

38

d)

42

10.

Read the code below:


alert(true || false);


What would the output be?

a)

True

b)

False

11.

Read the code below:


alert(false && true);


What would the output be?

a)

True

b)

False

12.

Read the code below:


alert(!false);


What would the output be?

a)

True

b)

False