wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

JavaScript Basics CodeHS

Total questions: 20

Worksheet time: 13mins

Name
Class
Date
1.
Indicates the beginning  and the end of a JavaScript section.
a)
<html> </html>
b)
<style> </style>
c)
<article> </article>
d)
<script> </script>
2.
A JavaScript file has an extension name of
a)
.jscp
b)
.js
c)
.css
d)
.Jp
3.
Which keyword do we need to define a function?
a)
function
b)
method
c)
onclick
d)
functionName()
4.
Which 1 of the following symbols is used for JavaScript comments?
a)
\\
b)
^
c)
?
d)
//
5.
In JavaScript, you should include a semi-colon at the end of each statement.
a)
yes
b)
no
6.
A JavaScript file has an extension name of
a)
.jscp
b)
.js
c)
.css
d)
.Jp
7.

Which command is written correctly?

a)

Move

b)

move

c)

Move();

d)

move();

8.

Which command is written incorrectly?

a)

putBall();

b)

putball();

c)

turnLeft();

d)

takeBall();

9.

Is this Function written correctly?

a)

True

b)

False

10.

What is the name of this function?

a)

function

b)

spin()

c)

3 turnLeft();

d)

spin();

11.

What can be used to teach Karel to turn right?

a)

Functions

b)

Variables

c)

Dog Treats

d)

Karel can already turn right

12.

This code:

putBall();

move();

putBall();

put 2 balls in the same place and then move one place?

a)

True

b)

False

13.
The conditional statement, in Javascript, begins with the word _______.
a)
Then
b)
Else
c)
If
d)
OK
14.
Which of the following best describes what a function is used for?
a)
they create new variable commands
b)
they are used for difficult math formulas
c)
they are reusable pieces of code that can be called any time in the program
d)
they allow for the use of mathematical operators
15.
What will happen if an infinite while loop is ran?
a)
the program will crash
b)
the computer will crash
c)
the loop will just keep running
d)
an error message will be displayed
16.
What surrounds a string?
a)
Quotations
b)
Curly Brackets
c)
Parenthesis
d)
Square Brackets
17.

Bonus Question: What is the web programming Trifecta?

a)

HTML, CSS, Javascript

b)

Java, C+, HTML

c)

Java, HTML, CSS

d)

Kobe, Labron, Jordan

18.

What is the syntax to declare a function called doSomething?

a)

function doSomething() { }

b)

doSomething() function { }

c)

function () doSomething { }

d)

doSomething { } function ()

19.

How many times does Karel move with this loop?

a)

9

b)

0

c)

10

d)

1

20.

Why do we use if/else statements in JavaScript?

a)

To repeat something for a fixed number of times

b)

To either do something if a condition is true or do something else

c)

To break out of some block of code

d)

To repeat something while a condition is true