WorksheetsProgramming with JavaScript Quiz
Total questions: 25
Worksheet time: 13mins
We never set the circle's radius. We need to add the line circle.setRadius(40); After line 4
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);
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);
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
Fernandez Florence
Florence Fernandez
FlorenceFernandez
Florence Fernandez
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?
user_age
UserAge
userAge
User age
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? ");
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? ");
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? ");
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? ");
println(distance/(time/60));
println(distance/time);
println(distance*(time*60));
println(distance*time);
1
2
3
4
5
25
30
50
Draws a circle to the center of the canvas with size based on user inputted value
Draws a circle on the canvas with the center positioned at the coordinate (0,0)
Draws a circle that is positioned in the bottom right corner of the canvas
Draw a circle on the canvas that always touches the top and left sides of the canvas
If a user enters a diameter value in the variable diameter, how would we use this to draw the correct sized circle?
var circle = new Circle(diameter); circle.setPosition(100,100); add(circle);
var circle = new Circle(diameter*2); circle.setPosition(100,100); add(circle);
var circle = new Circle(diameter/2); circle.setPosition(100,100); add(circle);
var circle = new Circle(diameter%2); circle.setPosition(100,100); add(circle);
A store has 20 apples in its inventory. How can you store this information in a JavaScript variable?
var numApples == 20;
20 = numApples;
var numApples = 20;
var 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?
var applesToBuy = readLine("How many apples would you like? ");
var applesToBuy = println("How many apples would you like? ");
var applesToBuy = readInt("How many apples would you like? ");
var applesToBuy = nextInt("How many apples would you like? ");
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 a graphics canvas, what are the coordinates of the bottom right corner of the window?
0, 0
0, getWidth()
getHeight(), getWidth()
getWidth(), getHeight()
What are the coordinates of the center of the window?
getWidth(), getHeight()
getWidth() / 2, getHeight() / 2
getHeight() - getWidth(), getWidth() - getHeight()
getHeight() / 2, getWidth() / 2
The x coordinate of the center of the circle
The x coordinate of the left edge of the circle
The radius of the circle
The position of the circle
Choose the best response: A function passed to an event handler that is called every time a certain event happens is called a
parameterized function.
return function.
callback function.
generator function.
Suppose we've written a function drawSquare that we want to call every time the mouse is clicked. How can we do this?
mouseClickMethod(drawSquare);
mouseClickMethod(drawSquare(e));
if(mouseClickMethod){ drawSquare(); }
mouseClickMethod(drawSquare());
This code snippet randomly places black circles on the screen.
This code snippet places a black circle on the screen and changes the radius every time the mouse is clicked.
This code snippet places a black circle on the screen with a radius of 35 in every place that the mouse is clicked.
This code snippet has an error and will not do anything.
What will be printed from the following: var x = 4 * 3 + 2 / 5; println(x);
12
12.4
4
13.6
Which of the following lines of code would be considered the highest level of code?
10110011010011101010
move();
movl $1, %eax
function move()
Which of the following could be considered a computer?
Smartphone
Digital coffee maker
Cars
All of these choices
4
2
18
8
1
3
5
10
What is your name? Rowan Hello Rowan
What is your name? Rowan Hello Rowan
What is your name? Rowan HelloRowan
Hello Rowan
12
3
27
c is undefined
