wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

JavaScript Basics Review

Total questions: 20

Worksheet time: 16mins

Name
Class
Date
1.

Where does JavaScript code go in an HTML document?

a)

<script> tag

b)

<html> tag

c)

<style> tag

d)

<button> tag

2.

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

a)

alert

b)

prompt

c)

console.log

d)

<p> tag

3.

Which of the following will successfully display a message to the user?

a)

Alert(Hello, user);

b)

alert("Hello, " user);

c)

Alert("Hello, user");

d)

alert("Hello, user");

4.

Which of the following will successfully display a message to the user?

a)

alert("hello, " + "user");

b)

Alert("hello, " + user);

c)

alert("hello", + "user");

d)

alert("Hello, " + user";

5.

What does this line of code do?

a)

Declares AND sets a variable

b)

Declares a variable

c)

Sets a variable

d)

Adds a value to a variable

6.

Which is NOT necessary when setting a variable?

a)

variable name

b)

equals sign

c)

value to set the variable to

d)

"var" keyword

7.

Which message will the user see?

a)

"I think you want a Sword I think"

b)

Depends what they answer

c)

"you want a Sword I think"

d)

"thinkingMessage + messageToShow + thinkingMessage"

8.
Which message will the user see?
a)
Depends what they answer
b)
"I think you want a Sword I think"
c)
"I think + you want a + Sword"
d)
"Sword Which item would you like to buy?"
9.
Which message will the user see?
a)
"Hello user"
b)
No message
c)
"Goodbye user"
d)
"message + user"
10.
What's the data type?
a)
String
b)
Number
11.

What's the data type for the phoneNumber variable?

a)

String

b)

Number

12.

What's the data type for the ageInput variable?

a)

String

b)

Number

13.

What's the data type for the age variable?

a)

String

b)

Number

14.

What's the value of the ageCalc variable?

a)

"19.27"

b)

26.2

c)

"25.7"

d)

19.27

15.
Which attribute do we need to link to an external JS file?
a)
src
b)
href
c)
script
d)
filename
16.

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();

17.
Which keyword do we need to define a function?
a)
function
b)
method
c)
onclick
d)
functionName()
18.

How do you make a button in HTML?

a)

<button>Text</button>

b)

<button text="Text"></button>

c)

<button>Text<button>

d)

<button Text>

19.

What is the syntax to declare a function called doSomething?

a)

function doSomething() { }

b)

doSomething() function { }

c)

function () doSomething { }

d)

doSomething { } function ()

20.
What is the name of the function in this example?
a)
sayHello
b)
sayHello()
c)
Say Hello
d)
onclick