wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Programming with JavaScript Quiz

Total questions: 25

Worksheet time: 13mins

Name
Class
Date
1.
a)

We never set the circle's radius. We need to add the line circle.setRadius(40); After line 4

b)

We are setting the position of the ball to be off the canvas. We need to change line 3 to be circle.setPosition(0, 0);

c)

We are creating the circle incorrectly. We need to specify the width and height. We need to change line 2 to be var circle = new Circle(40, 40);

d)

We create the circle and position it correctly on the screen, but we never add it to the screen. We need to add the line add(circle); after line 4

2.
a)

Fernandez Florence

b)

Florence Fernandez

c)

FlorenceFernandez

d)

Florence Fernandez

3.

Which of the following choices is a properly formed JavaScript variable name, meaning it is both legal in the JavaScript language and considered good style?

a)

user_age

b)

UserAge

c)

userAge

d)

User age

4.
a)

var x = readLine("What is the x coordinate? "); var y = readLine("What is the y coordinate? "); var radius = readLine("What is the radius of the circle? ");

b)

var x = readInt("What is the x coordinate? "); var y = readInt("What is the y coordinate? "); var radius = readLine("What is the radius of the circle? ");

c)

var x = readLine("What is the x coordinate? "); var y = readLine("What is the y coordinate? "); var radius = readInt("What is the radius of the circle? ");

d)

var x = readInt("What is the x coordinate? "); var y = readInt("What is the y coordinate? "); var radius = readInt("What is the radius of the circle? ");

5.
a)

println(distance/(time/60));

b)

println(distance/time);

c)

println(distance*(time*60));

d)

println(distance*time);

6.
a)

1

b)

2

c)

3

d)

4

7.
a)

5

b)

25

c)

30

d)

50

8.
a)

Draws a circle to the center of the canvas with size based on user inputted value

b)

Draws a circle on the canvas with the center positioned at the coordinate (0,0)

c)

Draws a circle that is positioned in the bottom right corner of the canvas

d)

Draw a circle on the canvas that always touches the top and left sides of the canvas

9.

If a user enters a diameter value in the variable diameter, how would we use this to draw the correct sized circle?

a)

var circle = new Circle(diameter); circle.setPosition(100,100); add(circle);

b)

var circle = new Circle(diameter*2); circle.setPosition(100,100); add(circle);

c)

var circle = new Circle(diameter/2); circle.setPosition(100,100); add(circle);

d)

var circle = new Circle(diameter%2); circle.setPosition(100,100); add(circle);

10.

A store has 20 apples in its inventory. How can you store this information in a JavaScript variable?

a)

var numApples == 20;

b)

20 = numApples;

c)

var numApples = 20;

d)

var num apples = 20;

11.

You want to read input from the user to know how many apples they would like to buy. Which statement should you use to read in a number from the user?

a)

var applesToBuy = readLine("How many apples would you like? ");

b)

var applesToBuy = println("How many apples would you like? ");

c)

var applesToBuy = readInt("How many apples would you like? ");

d)

var applesToBuy = nextInt("How many apples would you like? ");

12.

You are splitting up all of your apples equally between 3 people. Which statement below will calculate how many apples will be left over?

a)

var leftOver = numApples / 3;

b)

var leftOver = 3 / numApples;

c)

var leftOver = numApples % 3;

d)

var leftOver = 3 % numApples;

13.

In a graphics canvas, what are the coordinates of the bottom right corner of the window?

a)

0, 0

b)

0, getWidth()

c)

getHeight(), getWidth()

d)

getWidth(), getHeight()

14.

What are the coordinates of the center of the window?

a)

getWidth(), getHeight()

b)

getWidth() / 2, getHeight() / 2

c)

getHeight() - getWidth(), getWidth() - getHeight()

d)

getHeight() / 2, getWidth() / 2

15.
a)

The x coordinate of the center of the circle

b)

The x coordinate of the left edge of the circle

c)

The radius of the circle

d)

The position of the circle

16.

Choose the best response: A function passed to an event handler that is called every time a certain event happens is called a

a)

parameterized function.

b)

return function.

c)

callback function.

d)

generator function.

17.

Suppose we've written a function drawSquare that we want to call every time the mouse is clicked. How can we do this?

a)

mouseClickMethod(drawSquare);

b)

mouseClickMethod(drawSquare(e));

c)

if(mouseClickMethod){ drawSquare(); }

d)

mouseClickMethod(drawSquare());

18.
a)

This code snippet randomly places black circles on the screen.

b)

This code snippet places a black circle on the screen and changes the radius every time the mouse is clicked.

c)

This code snippet places a black circle on the screen with a radius of 35 in every place that the mouse is clicked.

d)

This code snippet has an error and will not do anything.

19.

What will be printed from the following: var x = 4 * 3 + 2 / 5; println(x);

a)

12

b)

12.4

c)

4

d)

13.6

20.

Which of the following lines of code would be considered the highest level of code?

a)

10110011010011101010

b)

move();

c)

movl $1, %eax

d)

function move()

21.

Which of the following could be considered a computer?

a)

Smartphone

b)

Digital coffee maker

c)

Cars

d)

All of these choices

22.
a)

4

b)

2

c)

18

d)

8

23.
a)

1

b)

3

c)

5

d)

10

24.
a)

What is your name? Rowan Hello Rowan

b)

What is your name? Rowan Hello Rowan

c)

What is your name? Rowan HelloRowan

d)

Hello Rowan

25.
a)

12

b)

3

c)

27

d)

c is undefined