wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Java Script BASICS

Total questions: 27

Worksheet time: 15mins

Name
Class
Date
1.
The command: ellipse( 200,100, 20, 20) will draw:
a)
an ellipse that is 100 pixels wide and 100 pixels high
b)
a circle whose center is 200 pixels across and 100 pixels down
c)
a rectangle that is 200 pixels by 100 pixels wide
d)
a circle that is 200 pixels in diameter
2.
After running the following code, what will be the value of x?
y = 3;
x = 5 * y;
a)
3
b)
5
c)
15
d)
0
3.
A variable is used to:
a)
Store a value in memory
b)
Draw a circle
c)
Store a value that does not change
d)
Draw a rectangle
4.
The following code section will:
x = 0;
draw = function() {
rectangle(x, 50, 50, 25);
x++;
}
a)
Draw lots of ellipses across the screen
b)
Draw lots of rectangles across the screen
c)
Draw a rectangle
d)
Draw an ellipse
5.
Any code that is within the following draw function:
draw = function(){
......
}
a)
Will be performed twice
b)
Will not be performed
c)
Will be performed once
d)
Will be repeated over and over again
6.
The following code will:
x++;
a)
Add 1 to the previous value of x
b)
Add 1 to the previous value of y
c)
Subtract 1 from the previous value of x
d)
Give an error message
7.
The following code will:
var xPos = 15;
var yPos = 350;
var xwidth = 50;
var ywidth = 50;
draw = function() {   
     background(29, 40, 115);   
     fill(255, 242, 0);   
     ellipse(xPos, yPos, xwidth, ywidth);              xPos++;   
     yPos--;   
     xwidth = xwidth* 99/100;   
     ywidth = ywidth * 99/100;
};
a)
Draw a circle that moves right to left accross the screen, getting smaller
b)
Draw a circle that moves diagonally accross the screen, getting bigger
c)
Draw a circle that moves diagonally accross the screen, getting smaller
d)
Draw a circle that moves right to left accross the screen, getting bigger
8.
The code:
draw = function() {
ellipse(mouseX, mouseY, 30, 30);
}
will:
a)
Draw a circle
b)
Draw many circles according to the mouse position
c)
Draw an oval
d)
Draw many circles in the center of the screen
9.
The output of the following code will be:
fill(0, 13, 255);
textSize(38);
text("Sophia", 99, 96);
a)
Sophia in colour blue
b)
"Sophia" in white
c)
The number 38
d)
A rectangle
10.
The following code will:
fill(255, 0, 255);
draw = function() {   
background(255, 255, 255);   
ellipse(mouseX, mouseY, 12, 12);   
var label = mouseX + "," + mouseY;    text(label,mouseX,mouseY);
};
a)
Draw a circle that follows the mouse
b)
Draws a circle that follows the mouse and displays the mouse coordinates
c)
Draws a circle at x =255 and y = 255
d)
Draws an oval
11.
A string is used for storing:
a)
Numbers
b)
Integers
c)
Images
d)
Text
12.
In the following code:
var add = function(num1, num2) {   
return num1 + num2;
};
The function will receive two numbers and: 
a)
Add them
b)
Return them
c)
Add them then return their sum
d)
Find their difference
13.
What command draws a rectangle?
a)
rec (10, 20, 100, 200);
b)
rect (10, 20, 100, 200)
c)
rect (10, 20, 100, 200);
d)
ellipse (10, 20, 40, 40)
14.
What command draws a rectangle?
a)
rec (10, 20, 100, 200);
b)
rect (10, 20, 100, 200)
c)
rect (10, 20, 100, 200);
d)
ellipse (10, 20, 40, 40)
15.
Which command colors the background of your canvas?
a)
background 
b)
endShape
c)
var = color
d)
fill
16.
What command removes the outlines from shapes?
a)
noOutline ();
b)
noColor();
c)
noBorder();
d)
noStroke ();
17.
What command draws a perfect circle?
a)
ellipse (80, 60, 100, 105);
b)
ellipse(80, 60, 100, 100);
c)
circle (80, 60, 80, 60):
d)
ellipse (80, 60, 105, 100);
18.
What command colors a shape?
a)
color (43, 255, 0);
b)
bucket (43, 255, 0);
c)
fill (43, 255, 0);
d)
bucket (43, 255, 0);
19.
What command draws a line?
a)
stroke (200, 220, 275, 220);
b)
line (200, 220, 275, 220);
c)
horizontal (200, 220,  60, 75);
d)
pencil (200, 220, 275, 220);
20.
What is at the end of a line of code?
a)
#
b)
;
c)
)
d)
>
21.
How do you turn in your JavaScript assignment?
a)
A link to the Padlet
b)
Click finished in Khan Academy
c)
Add link Spin off link to Google Classroom
d)
Print it out
22.
Which command colors the background of your canvas?
a)
background 
b)
endShape
c)
var = color
d)
fill
23.
What command removes the outlines from shapes?
a)
noOutline ();
b)
noColor();
c)
noBorder();
d)
noStroke ();
24.
What command colors a shape?
a)
color (43, 255, 0);
b)
bucket (43, 255, 0);
c)
fill (43, 255, 0);
d)
bucket (43, 255, 0);
25.
What command draws a line?
a)
stroke (200, 220, 275, 220);
b)
line (200, 220, 275, 220);
c)
horizontal (200, 220,  60, 75);
d)
pencil (200, 220, 275, 220);
26.
What is at the end of a line of code?
a)
#
b)
;
c)
)
d)
>
27.

What keyword do you need to use to define a variable in JavaScript?

a)

println

b)

var

c)

float

d)

int