NEW
Font size
WorksheetsJavaScript Basics & Graphics Test
Total questions: 25
Worksheet time: 13mins
Which of the following commands is a valid Karel command?
move
move;
move();
move()
What are the horizontal pathways called in a Karel world?
rows
points
columns
Karel’s position
What are the vertical pathways called in a Karel world?
rows
columns
points
Karel's position
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();
Row 1 and Column 3
Row 4 and Column 4
Row 2 and Column 6
Row 6 and Column 2
What is the purpose of using a for loop in code?
To do something if a condition is true
To make programs run faster
To repeat something a fixed number of times
To do something while a condition is true
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();
}
Karel is on a spot with a tennis ball facing north
Karel is facing East.
Karel ends one spot above a tennis ball facing East.
Karel is on the same position but on top of a ball.
How can we improve the following program?
function main() {
move();
move();
move();
move();
move();
move();
move();
}
main();
Break down this program into more functions
Use a for loop to repeat the move command
Fix the indentation of this program
Use a while loop to repeat the move command
What is top down design?
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.
Top down design is a way that you can create designs on a computer to put on a web page
Top down design is a way of designing your programs starting with the individual commands first
Top down design is a way to use loops and if statements to decompose the problem
A store has 20 apples in its inventory. How can you store this information in a JavaScript variable?
let numApples == 20;
20 = numApples;
let numApples = 20;
let num apples = 20;
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?
let applesToBuy = readInt("How many apples would you like? ");
let applesToBuy = nextInt("How many apples would you like? ");
let applesToBuy = console.log("How many apples would you like? ");
let applesToBuy = readLine("How many apples would you like? ");
What is printed to the screen when the following program is run?
var num = 13 % 3;
console.log(num);
1
2
3
4
What type of data can we NOT randomly generate using the Randomizer?
Colors
Floats
Booleans
Strings
Integers
What is the correct keyword to create a constant variable?
def
let
constant
const
What function do you need to call to get the width of the canvas?
getWidth();
width();
canvasWidth();
getCanvasWidth();
Where is the anchor point of a circle located?
Left edge
Center
Top edge
Right edge
Bottom edge
Where is the anchor point of a rectangle located?
Top left corner
Top right corner
Center
Bottom left corner
Bottom right corner
True or False: All Text objects are bounded by an invisible rectangular box.
True
False
Where is the anchor point of a Text object located?
Top left
Top right
Center
Bottom left
Bottom right
You are splitting up all of your apples equally between 3 people.
Which statement below will calculate how many apples will be left over?
var leftOver = numApples / 3;
var leftOver = 3 / numApples;
var leftOver = numApples % 3;
var leftOver = 3 % numApples;
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?
The x coordinate of the center of the circle
The radius of the circle
The x coordinate of the left edge of the circle
The position of the circle
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);
Florence
Fernandez
Florence Fernandez
FlorenceFernandez
Fernandez Florence
Is JavaScript case-sensitive?
Yes
No
A variable name can begin with a
letter
dollar sign
underscore character
All of the above
All JavaScript statements end with a
Semicolon
Question mark
Period
Hashtag
What data type would be best for the following data: true
string
boolean
integer
float
