Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Introduction to Javascript Programming

Total questions: 16

Worksheet time: 7mins

Name
Class
Date
1.
When drawing in Javascript, the coordinates for the top left of the screen is:
a)
0,400
b)
0,0
c)
400,0
d)
400,400
2.
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
3.
ellipse(212, 206, 283, 318);
ellipse(212, 235, 100, 73);
ellipse(150, 150, 30, 30);
ellipse(278, 150, 30, 30);
The code above represents a snowman with two eyes and a nose. The code that represents the nose is:
a)
ellipse(150, 150, 30, 30);
b)
ellipse(212, 206, 283, 318);
c)
ellipse(212, 235, 100, 73);
d)
ellipse(212, 235, 100, 73);
4.
The function background(100,0,0) will colour the background in:
a)
red
b)
green 
c)
blue
d)
transparent
5.
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
6.
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
7.
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
8.
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
9.
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
10.
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
11.
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
12.
The following code will:
var faceX = random(50, 350);
a)
Produce a random number between 0 and 50
b)
Produce a random number
c)
Produce a random number between 50 and 350
d)
Produce 50 random numbers
13.
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
14.
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
15.
A string is used for storing:
a)
Numbers
b)
Integers
c)
Images
d)
Text
16.
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