wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

JavaScript Basics & Graphics Test

Total questions: 25

Worksheet time: 13mins

Name
Class
Date
1.

Which of the following commands is a valid Karel command?

a)
  1. move

b)
  1. move;

c)
  1. move();

d)
  1. move()

2.

What are the horizontal pathways called in a Karel world?

a)
  1. rows

b)
  1. points

c)
  1. columns

d)
  1. Karel’s position

3.

What are the vertical pathways called in a Karel world?

a)

rows

b)

columns

c)

points

d)

Karel's position

4.

If Karel starts facing East in the first row, third column, what row and column will Karel be on after this code runs?

move();

move();

move();

turnLeft();

move();

a)

  1. Row 1 and Column 3

b)
  1. Row 4 and Column 4

c)
  1. Row 2 and Column 6

d)
  1. Row 6 and Column 2

5.

What is the purpose of using a for loop in code?

a)
  1. To do something if a condition is true

b)
  1. To make programs run faster

c)
  1. To repeat something a fixed number of times

d)
  1. To do something while a condition is true

6.

In the following code, what would be a good Postcondition to write?

/* Precondition: Karel is on a spot with a tennis ball facing East

Postcondition: ... /

function getOnTop() {

turnLeft();

move();

turnRight();

}

a)
  1. Karel is on a spot with a tennis ball facing north

b)
  1. Karel is facing East.

c)
  1. Karel ends one spot above a tennis ball facing East.

d)
  1. Karel is on the same position but on top of a ball.

7.

How can we improve the following program?

function main() {

move();

move();

move();

move();

move();

move();

move();

}

main();

a)

  1. Break down this program into more functions

b)
  1. Use a for loop to repeat the move command

c)
  1. Fix the indentation of this program

d)
  1. Use a while loop to repeat the move command

8.

What is top down design?

a)


Top down design is a way of designing your program by starting with the biggest problem and breaking it down into smaller and smaller pieces that are easier to solve.

b)


Top down design is a way that you can create designs on a computer to put on a web page

c)

Top down design is a way of designing your programs starting with the individual commands first

d)

Top down design is a way to use loops and if statements to decompose the problem

9.

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

a)
  1. let numApples == 20;

b)
  1. 20 = numApples;

c)
  1. let numApples = 20;

d)

let num apples = 20;

10.

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)

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

b)

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

c)

let applesToBuy = console.log("How many apples would you like? ");

d)

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

11.

What is printed to the screen when the following program is run?

var num = 13 % 3;

console.log(num);

a)

1

b)

2

c)

3

d)

4

12.

What type of data can we NOT randomly generate using the Randomizer?

a)
  1. Colors

b)
  1. Floats

c)
  1. Booleans

d)
  1. Strings

e)
  1. Integers

13.

What is the correct keyword to create a constant variable?

a)

def

b)
  1. let

c)
  1. constant

d)
  1. const

14.

What function do you need to call to get the width of the canvas?

a)

  1. getWidth();

b)
  1. width();

c)
  1. canvasWidth();

d)
  1. getCanvasWidth();

15.

Where is the anchor point of a circle located?

a)
  1. Left edge

b)
  1. Center

c)
  1. Top edge

d)
  1. Right edge

e)
  1. Bottom edge

16.

Where is the anchor point of a rectangle located?

a)
  1. Top left corner

b)

  1. Top right corner

c)
  1. Center

d)
  1. Bottom left corner

e)
  1. Bottom right corner

17.

True or False: All Text objects are bounded by an invisible rectangular box.

a)

True

b)

False

18.


Where is the anchor point of a Text object located?

a)

  1. Top left

b)
  1. Top right

c)
  1. Center

d)
  1. Bottom left

e)
  1. Bottom right

19.

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;

20.

In the following code:

var size = 20;

var x = 100;

var y = 200;

var ball = new Circle(size);

ball.setPosition(x, y);

What is the meaning of the x variable?

a)

The x coordinate of the center of the circle

b)

The radius of the circle

c)

The x coordinate of the left edge of the circle

d)

The position of the circle

21.

What is the output of the following program: (Assume the user enters ‘Florence’ then ‘Fernandez’.)

var first_name = readLine("What is your first name? ");

var last_name = readLine("What is your last name? ");

var whole_name = first_name + last_name;

console.log (whole_name);

a)

Florence
Fernandez

b)

Florence Fernandez

c)

FlorenceFernandez

d)

Fernandez Florence

22.

Is JavaScript case-sensitive?

a)

Yes

b)

No

23.

A variable name can begin with a

a)

letter

b)

dollar sign

c)

underscore character

d)

All of the above

24.

All JavaScript statements end with a

a)

Semicolon

b)

Question mark

c)

Period

d)

Hashtag

25.

What data type would be best for the following data: true

a)

string

b)

boolean

c)

integer

d)

float