wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Intro to JavaScript

Total questions: 20

Worksheet time: 10mins

Name
Class
Date
1.
Let's say you defined a function called startTheParty in your program. What line of code would call that function?
a)
startTheParty;
b)
startTheParty();
c)
var startTheParty = true;
d)
var startTheParty();
2.
You want to define a function for drawing houses and then use it to draw multiple houses. Where should you define that function?
a)
At the beginning of the program, before you call it.
b)
Right after you call it.
c)
At the very end of the program.
d)
It doesn't matter one bit!
3.
Which of these lines of code correctly define a function?
a)
var dropTheBeat = function() [ ];
b)
dropTheBeat = function() { };
c)
var dropTheBeat = function() { };
d)
var dropTheBeat = function { };
4.
Which of these lines of code define a function that takes 2 parameters?
a)
var funkyFunc = function(note, tempo) { };
b)
var funkyFunc = function() { };
c)
var funkyFunc = function([note, tempo]) { };
d)
var funkyFunc = function() {
   var note, tempo;
}; 
5.
You have a function named funkyFunc that takes 2 parameters. What line of code validly calls it and passes in 2 values?
a)
funkyFunc = 'A', 20;
b)
funkyFunc('A' 20);
c)
funkyFunc(['A', 20]);
d)
funkyFunc('A', 20);
6.
You've defined a function named calcAge that takes three parameters (day/month/year) and returns a value. How do you call that function and store the resulting value?
a)
var calcAge(24, 6, 1984);
b)
var age = calcAge(24, 6, 1984);
c)
var age = calcAge(24/6/1984);
d)
var age = calcAge = 24, 6, 1984;
7.
What keyword do you need to use if you want your function to return a value?
a)
return
b)
echo
c)
sendback
d)
reply
8.
Which of these lines of JS code are syntactically correct?
a)
rect(100, 100, 50, 50);
b)
rect[100, 100, 50, 50];
c)
rect(100 100 50 50);
d)
rect(100, 100, 50, 50):
9.
Which of these lines of JS code are syntactically correct?
a)
ellipse(100; 100; 50; 50);
b)
ellipse(100 100 50 50);
c)
ellipse  (100, 100, 50, 50)
d)
ellipse(100, 100, 50, 50);
10.
In the  Khan Academy programming environment, where is the point (0, 0)?
a)
upper left corner
b)
center
c)
upper right corner
d)
lower left corner
11.
How many parameters should you pass to the line() function?
a)
1
b)
2
c)
4
d)
6
12.
Which of these function calls draws a perfect circle?
a)
ellipse(100, 100, 200, 50);
b)
ellipse(50, 200, 100, 100);
c)
ellipse(50, 100, 100, 200);
d)
ellipse(100, 50, 200, 100);
13.
For the line() function, what numbers should you pass to the third and fourth parameters?
a)
The width and height of the line
b)
The end x position and end y position of the line
c)
The amount to rotate and skew the line
d)
Your 2 favorite numbers in the world
14.
Which of these function calls draws a square?
a)
rect(100, 100, 75, 60);
b)
rect(75, 60, 100, 100);
c)
rect(100, 60, 75, 100);
d)
rect(60, 100, 100, 75);
15.
What ProcessingJS function can you call to change the color of the entire canvas?
a)
setBackground()
b)
background()
c)
canvasColor()
d)
fill()
16.
What function should you call to change the color of a line in your program?
a)
fill()
b)
outline()
c)
stroke()
d)
color()
17.
If you're programming a drawing, where should your background() call be?
a)
At the beginning of the program
b)
At the end of the program
c)
At the beginning AND end of the program
d)
After the first rect()
18.
The fill() function takes 3 parameters. What do those three numbers represent?
a)
red, green, blue
b)
cyan, magenta, yellow
c)
color, saturation, opacity
d)
red, yellow, blue
19.
What function can you call to remove the outlines from all the shapes in your program?
a)
noFill();
b)
noStroke();
c)
noOutlines();
d)
noLines();
20.
What are the minimum and maximum values of the 3 numbers that get passed into fill() and stroke()?
a)
0 - 100
b)
0 - 50
c)
115 - 255
d)
0 - 255