Miscellaneous
Functions
Animation
Functions and Parameters
Graphics in JavaScript
100

function quadrupleNumber(x){
    var quadX = 4 * x;
    println(quadX);
}

What is the parameter of the function quadrupleNumber?

x

100

Which function begins each program?

the start function

100

Which statement will call a function animate every 50 milliseconds?

setTimer(animate, 50);

100

Why do we write functions?

  • Make our code easier to understand by giving a readable name to a group of instructions    

  • Avoid writing repeated code        

  • Make our code reusable

100

var coolCircle = new Circle(30);

What does the 30 represent?

the radius

200

FREE 200 POINTS GO AGAIN!!!

FREE 200 POINTS GO AGAIN!!!

200

True or False:

Naming functions properly is very important.

true

200

How would you stop the timer in a program that contained this command:

setTimer(draw, 50);

stopTimer(draw);

200

FREE 200 POINTS AND GO AGAIN!!!

FREE 200 POINTS AND GO AGAIN!!!

200

What are the coordinates in the upper left corner of the screen?

(0,0)

300

Karel is facing east. How many times does Karel need to turn left to face west?

twice

300

Functions allow us to break down our program into smaller parts, and make the program _________.

easier to understand

300

FREE 300 POINTS GO AGAIN!!!

FREE 300 POINTS GO AGAIN!!!

300

If we want to draw a circle using our helpful drawCircle function at position (300, 400) with a radius of 40 and color blue, which is the correct function call? You don't need to say the word function...you aren't defining it you are calling it.

function drawCircle(radius, color, x, y)


drawCircle(40, Color.blue, 300, 400);

300

What is wrong with this command?

var rect = new rectangle(30,120);

"rectangle" should be capitalized

400

In a graphics canvas, what are the coordinates of the center of the canvas?

getWidth() / 2, getHeight() / 2

400

What are you doing when you are defining a function?

You are specifying the instructions (writing the code) for that function.

400

Sorry you lost your turn.

Sorry you lost your turn.

400

SORRY YOU LOST YOUR TURN!!!

SORRY YOU LOST YOUR TURN!!!

400

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

getWidth();

500

What three programming languages do web developers often use together

HTML

JavaScript

CSS

500

What are you doing when you are calling a function? 

You are causing the action/function to actually happen.

500

Will this statement determine if ball is hitting the left edge of the window?

if(ball.getX() - ball.getRadius() <= 0){
    //ball is hitting left edge
}

yes

500

How many return values come out of the function sum?

function sum(first, second){
    var result = first + second;
    return result;
}

one

500

What are the coordinates of the top right corner of the screen?

getWidth(), 0