code
What symbol do you use to do division in JavaScript?
*
What is printed to the screen when the following program is run? let num = 13 % 3; console.log(num);
1
Given what you learned about how Randomizer.nextInt() works, and what you know about booleans, how many possible values can Randomizer.nextBoolean() return?
2
let circ = new Circle(20); circ.setPosition(getWidth() / 2, getHeight() / 2); circ.setColor("blue"); add(circ); What would be the value of circ.getRadius();?
20
What is printed to the screen if the user enters '5' when the following program is run? let userNum = readInt("Enter your favorite number: "); let calculatedNum = (userNum * userNum) + userNum; console.log(calculatedNum);
30
What will the following code print to the screen? console.log(2 + 2);
4
To ask the user of the program for a number, which function should you use?
Both readInt and readFloat are for numbers.
Where is the anchor point of a circle located?
Center
Which of the following is NOT a benefit of pair-programming?
Code takes 15% less time to write than with a solo programmer.
What is the difference between calling and defining a function?
Defining a function is when you determine what a function does. Calling a function is when you want to use a function in your program.
The y-coordinate increases as you move in which direction?
Down
What is the output of the following program: (Assume the user enters 'Florence' then 'Fernandez'.) let firstName = readLine("What is your first name? "); let lastName = readLine("What is your last name? "); let wholeName = firstName + lastName; console.log(wholeName);
FlorenceFernandez
function main() { } function hello() { console.log("Hello!"); } main(); Consider the following code:, where would we call the hello function?
On line 2, inside of the main function.
Which of the following returns a random decimal number between 1 and 10?
Randomizer.nextFloat(1, 10);
Which of the following returns a random number between 1 and 10?
Randomizer.nextInt(1, 10)
What type of data can we NOT randomly generate using the Randomizer?
Strings
What type of data needs to be passed into the parentheses of the Text constructor?
Strings
When creating a new image object, what goes inside of the parentheses?
The image's URL
In the following code, we create a circle and add it to the canvas. What is the meaning of the x variable? let x = 20; let circle = new Circle(x); add(circle);
The radius of the circle
What is the role of the driver in a pair-programming setting?
They control the mouse and keyboard
Why do we write functions?
To make our code easier to understand and to avoid writing repeated code / make our code reusable
Where is the anchor point of a rectangle located?
Top left corner
What part of an image object is anchored to the canvas?
Top left of the image
function main(){ 2 let circle = new Circle(40); 3 circle.setPosition(getWidth() / 2, getHeight() / 2); 4 circle.setColor("blue"); 5 } main(); What is missing from our main function?
We need to add the line [add(circle);] after line 4
What is the proper function to call to print to the screen?
console.log
let distance = 2; let time = 30; What line of code would print the speed in km/hr if the distance is given in km and the time is given in minutes? (Speed = distance / time)
console.log(distance / (time / 60));
What is the correct keyword to create a constant variable?
const
What would be the correct way to name a function that tells us the day of the week?
function dayOfWeek() { ... }
In a graphics canvas, what are the coordinates of the center of the canvas?
getWidth() / 2, getHeight() / 2
In a graphics canvas, what are the coordinates of the bottom right corner of the canvas?
getWidth(), getHeight()
What function do you need to call to get the width of the canvas?
getWidth();
What keyword do you need to use to define a variable in JavaScript?
let
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? ");
You are splitting up all of your apples equally between 3 people. Which statement below will calculate how many apples will be left over?
let leftOver = numApples % 3;
Which line of code is the correct way to add a line to the canvas?
let ln = new Line(100, 50, 300, 200);
A store has 20 apples in its inventory. How can you store this information in a JavaScript variable?
let numApples = 20;
If we want to generate a random number where 5 is the smallest number possible and 10 is the largest number possible, which line of code would be correct?
let rand = Randomizer.nextInt(5, 10);
a rectangle is covering the left third of the canvas What are the correct width and height values for this rectangle?
let rect = new Rectangle(getWidth() / 3, getHeight());
What function do you need to call to ask the user of the program to enter text?
readLine
The x-coordinate increases as you move in which direction?
right
function rollDice() { let roll1 = Randomizer.nextInt(1, 6); let roll2 = Randomizer.nextInt(1, 6); console.log("You rolled " + roll1 + " and " + roll2); } How would you call this function?
rollDice();
Which of the following is part of the navigator's role in pair-programming?
thinking of alternative ways to solve the problem
Where is the origin of the canvas located?
top left
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?
userAge