wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

JS- Animation Basics - Intro to Programming - KhanAcademy

Total questions: 100

Worksheet time: 54mins

Name
Class
Date
1.

The set of rules that must be followed when writing program instructions for a specific programming language is called:

a)

executing

b)

machine language.

c)

binary.

d)

syntax

2.

To a computer: main and Main are exactly the same thing

a)

TRUE

b)

FALSE

3.

A syntax error

a)

is when the program is coded correctly, but an error occurs because of a problem while the program is being executed (not because of a mistake in the code)

b)

is when incorrect words or punctuation is used, or when correct words and punctuation are used in the wrong order

c)

is when the stars don't line up properly and a cosmic ray changes a true value to a false value

d)

is when the program is coded incorrectly to produce an incorrect result, but with correct statements. The only way to know there was an error is to notice that the result is wrong

4.

A logic error

a)

is when the program is coded correctly, but an error occurs because of a problem while the program is being executed (not because of a mistake in the code)

b)

is when incorrect words or punctuation is used, or when correct words and punctuation are used in the wrong order

c)

is when the stars don't line up properly and a cosmic ray changes a true value to a false value

d)

is when the program is coded incorrectly to produce an incorrect result, but with correct statements. The only way to know there was an error is to notice that the result is wrong

5.

A named location in memory where a value can be stored is called

a)

an operator

b)

a variable

c)

a keyword

d)

a process

6.

What type of data would either True or False be?

a)

String

b)

Character

c)

Real

d)

Boolean

7.

Which of the following is NOT a mathematical operator?

a)

+

b)

=

c)

/

d)

&

8.

Which of the following is a relational operator?

a)

+

b)

-

c)

/

d)

>

9.

Which of the following is a logical operator?

a)

IF

b)

THEN

c)

AND

d)

ELSE

10.

Which of the following is NOT a logical operator?

a)

AND

b)

OR

c)

NOT

d)

IF

11.

In this algorithm, which of the following is a variable?

a)

password

b)

loop

c)

output

d)

while

12.

TRUE or FALSE:

Variables cannot be changed.

a)

True

b)

False

13.

TRUE or FALSE:

Variable names can include spaces.

a)

False

b)

True

14.
An IF statement is triggered by....
a)
Conditions
b)
Comments
c)
Loops
d)
Time
15.

Which of the following statements can be used to extend selection from a single IF statement?

a)

ELSE

b)

DO

c)

CHOICE

d)

FOR

16.

Which of the following is NOT a selection statement?

a)

FOR

b)

IF

c)

ELSE

d)

ELSE IF

17.

Which of the following is a count-controlled loop?

a)

FOR

b)

IF

c)

WHILE

d)

DEF

18.

The variable 'x' starts at 0. It is incremented by 1, each loop.


Which of the following will run the loop exactly 10 times?

a)

WHILE x < 10

b)

WHILE x < 9

c)

WHILE x < 11

d)

WHILE x > 1

19.

Which of these is a loop?

a)

if(x<10)

b)

while(x<10)

c)

var x=10;

d)

text(x,10;10)

20.

Which of these will increase the value of the variable X?

a)

increment (x)

b)

x++;

c)

x=x;

d)

x+1;

21.

Which of the following will decrease the value of x?

a)

x--;

b)

x-1;

c)

x=x;

d)

x=-x;

22.

His name is Fred and he is less than 16 years old

a)

if (name = "fred" && age < 16 )

b)

if (name === "fred" && age < 16 )

c)

if (name = "fred" || age < 16 )

d)

if (name === "fred" || age < 16 )

23.

Repeat something 10 times

a)

repeat 10

b)

for (var i=0; i<10; i++)

c)

repeat { } until 10;

d)

while (i = 10)

24.

When we are done with a line what do we put at the end?

a)

a colon :

b)

a semi-colon ;

c)

a period .

d)

a quotation mark "

25.

A short form writing the word variable is

a)

rav

b)

VAR

c)

var

d)

varia

26.
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)
27.

Which message will the user see?

a)

"Hello user"

b)

No message

c)

"Goodbye user"

d)

"message + user"

28.

How do I declare a new variable?

a)

var newVariable = 5

b)

Variable int = new Variable()

c)

var 5 = myVariable

d)

int var = 5

29.

What surrounds an if/else statement?

a)

Quotations " "

b)

Curly Brackets { }

c)

Parenthesis ( )

d)

Square Brackets [ ]

30.

Which one of the following is the symbol for implementing the OR operator?

a)

**

b)

&&

c)

||

d)

!

31.

Which one of the following is the symbol for implementing the AND operator?

Lequel des symboles suivants est utilisé pour implémenter l’opérateur AND?

a)

&&

b)

**

c)

||

d)

++

32.

Why do we use if/else statements in JavaScript?

a)

To repeat something for a fixed number of times

b)

To either do something if a condition is true or do something else

c)

To break out of some block of code

d)

To repeat something while a condition is true

33.

What's the value of the ageCalc variable?

a)

"19.27"

b)

26.2

c)

"25.7"

d)

19.27

34.

In JavaScript, which of the following operator symbols means not equal to?

a)

<>

b)

==

c)

!=

d)

##

35.

A loop that executes for a pre-defined number of times

(a)  

36.

A loop that executes until a condition is met is called

(a)  

37.

Which of the below are types of loops

a)

if then else

b)

while loop

c)

for loop

38.

Nested loops are

a)

Multiple independent loops

b)

Conditions in a loop

c)

Loop in a Loop

d)

Loop in a condition

39.

for ( var i = 0; i < 50; i++ )


How many times will this loop execute

a)

51 times

b)

49 times

c)

50 times

d)

0 times

40.

Which of the iterations runs 25 times

a)

for ( var i = 2; i < 26; i ++ )

b)

for ( var i = 0; i < 25; i ++ )

c)

for ( var i = -1 ; i > 25 ; i -- )

d)

for ( var i = 0; i <= 25; i --)

41.

One of the below functions lets you climb 1000 feet

a)

for ( var count = 0; count > 999; count --)

moveUpOneFoot();

}

b)

for ( var count = 2; count <= 1001; count ++)

moveUpOneFoot();

}

c)

for ( var count = 1000; count < 1; count --)

moveUpOneFoot();

}

d)

for ( var count = 0; count < 1000; count ++)

moveUpOneFoot();

}

42.

How do you define a function in JavaScript

a)

function = climbUp();

b)

fun = "climbUp";

c)

function climbUp();

d)

fun = (climbUp());

43.

Loops in programming start counting from ?

a)

0

b)

1

c)

Any number

44.

What symbol represents the or operator in JavaScript?

a)

OR

b)

or

c)

||

d)

|

45.
Arithmetic Operators
What is ++ ?
a)
Modulo
b)
increment
c)
Decrement
d)
Addition
46.
Which one of the following is NOT a logical operator?
a)
||
b)
&&
c)
$$
d)
!
47.

Names that refer to commands, functions, variables and keyword should be written correctly, variable “A” and “a” are two different variables.

a)

Comments

b)

Case Sensitivity

c)

Data Types

d)

Statements

48.
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
49.

Which of the following is the correct Javascript format for a comment?

a)

// "the text"

b)

/"the text"/

c)

*/"the text"/*

d)

\\"the text

50.
The conditional statement, in Javascript, begins with the word _______.
a)
Then
b)
Else
c)
If
d)
OK
51.
What will happen if an infinite while loop is ran?
a)
the program will crash
b)
the computer will crash
c)
the loop will just keep running
d)
an error message will be displayed
52.

Is this Function written correctly?

a)

True

b)

False

53.

What is the name of this function?

a)

function

b)

spin()

c)

3 turnLeft();

d)

spin();

54.

Changes the flow of the code.

a)

Indentation

b)

Condition

c)

Control Structure

d)

Parentheses

55.

Repeat code as long as something is true.

a)

While Loop

b)

Loop

c)

If Statement

d)

For Loop

56.

Repeat code a fixed number of times.

a)

While Loop

b)

Loop

c)

If Statement

d)

For Loop

57.

Which of these will decrease the value of the variable X?

a)

decrement (x)

b)

x--;

c)

x-x;

d)

x-1;

58.

In JavaScript, which of the following operator symbols means equal to?

a)

<>

b)

==

c)

=

d)

##

59.

What's different about the coordinate system that we use when drawing on the screen of a digital device?

a)

We draw in the 4th quadrant of the coordinate plane when drawing on the monitor.

b)

The y-axis is inverted

c)

The x-axis is inverted

d)

We draw in the 2nd quadrant of the coordinate plane when drawing on the monitor.

60.

_________ is written text or illustration that accompanies computer software or is embedded in the source code. The documentation either explains how the software operates or how to use it, and may mean different things to people in different roles.

a)

Software Documentation

b)

Python

c)

Javascript

d)

Multi line comments

61.

The expression score = score +10 can be written as

a)

score += 10;

b)

score ++= 10;

c)

score =+ 10;

d)

score + 10 = 10;

62.

One of the answers is not correct as increment by one:

a)

a++

b)

a =+1

c)

a= a+1

d)

a += 1

63.

Which of these code snippets is the most readable, according to the JavaScript coding style conventions that we recommend here?

a)
b)
c)
64.

Which of these code snippets is the most readable, according to the JavaScript coding style conventions that we recommend here?

a)
b)
c)
65.
An array is;
a)
Shapes
b)
Sizes
c)
Options
d)
Lists of data
66.
What surrounds an array?
a)
Quotations
b)
Curly Brackets
c)
Parenthesis
d)
Square Brackets
67.

What is first index value of an array?

a)

-1

b)

0

c)

1

d)

undefine

68.
array = [1,2,3,4,5]
What is the length of this array?
a)
5
b)
4
c)
0
d)
125.4
69.

Which definition below best describe an array?

a)

An array is a function identifier that can hold more than one parameter.

b)

An array is a beam of light.

c)

An array is a special variable, which can hold more than one value at a time.

d)

An array is a special function, which can hold more than one value at a time.

70.

What is proper syntax for declaring a array in JavaScript?

a)

var arrayName =[ ];

b)

var arrayName[ ] ={ };

c)

array arrayName ={ };

d)

obj var arrayName =[ ];

71.

Which of the variables below is an array?

a)

var names="array"

b)

var names = array;

c)

var names = [];

d)

var names[];

72.
How would you change the first element in an array?
a)
nums[1] = "New!";
b)
nums = "New!";
c)
var nums[1] = "New!";
d)
nums[0] = "New!";
73.
array = [1,2,3,4,5];
What is the highest position in this array?
HINT: Remember arrays start at position 0!
a)
4
b)
5
c)
0
d)
125.7
74.
What property tells you how many items are in an array?
a)
length
b)
count
c)
items
d)
num
75.

How would you access the second element in an array?

a)

nums.2

b)

nums[2]

c)

nums_1

d)

nums[1]

76.
Which of these lines of code show how to validly store an array with 3 items?
a)
var nums = [42, 3, 7];
b)
var nums = 3, 42, 7;
c)
var nums = [3];
d)
var nums = (3, 42, 7);
77.

What will be the output to the console for the following code:


var colors =["Red", "Green", "Yellow", "Orange", "Blue"];

colors.splice(0,3, "Purple");

console.log(colors);

a)

["Purple", "Green", "Yellow"]

b)

["Purple", "Green", "Yellow", "Orange", "Blue"]

c)

["Red", "Green", "Yellow", "Orange", "Blue"]

d)

["Purple", "Orange", "Blue"]

78.

The push() method adds a new element to the end of an array

a)

true

b)

false

79.
Which of these for loops would iterate through each item of the nums array (no more, no less)?
a)
for (var i = 0; i < nums; i++) { }
b)
for (var i = 1; i < nums.length; i++) { }
c)
for (var i = 1; i < nums; i++) { }
d)
for (var i = 0; i < nums.length; i++) { }
80.

His name is Fred and he is less than 16 years old

a)

if (name = "fred" && age < 16 )

b)

if (name === "fred" && age < 16 )

c)

if (name = "fred" || age < 16 )

d)

if (name === "fred" || age < 16 )

81.

What is Concatentation

a)

The process of joining strings and variables

b)

The process of inputting data into a variable

c)

The way we find errors in a program

d)

The way selection is used

82.

Which is of the following not correct rule for writting variables names.

a)

These need to be in the lowercase or camel case

b)

spaces are allowed while naming these.

c)

These could be mix of letters, Numbers, _ or $

d)

you cannot start with a number

83.

One of the follwing statements is correct

a)

var myVariable = "Hello"

b)

var myVariable = /Hello/

c)

var myVariable = "Hello'

d)

var myVariable = Hello

84.

You will always find these in pairs if you have an opening one you will find a closing one as well. Even if it is after many multiple lines.

a)

{ Braces}

b)

[ Brackets ]

c)

( Parentheses )

d)

All

85.

which the camel case variable name is correct

a)

var my _code_date = "c"

b)

var myCodeDate = "c"

c)

var MycodeDate = "c"

d)

var MyCodeDate = "c"

86.
How do we generate a random number?
a)
Math.random()
b)
random.number()
c)
number.random()
d)
Random.math()
87.

Which of the following is TRUE about lists.

a)

They can't change size

b)

They can only hold numbers

c)

The order of items is not kept

d)

Lists can be stored in a variable

88.

In a list each item is assigned a number in that list. That number is called the ________?

a)

location

b)

index

c)

identifier

d)

list code

89.

given the list

var names = ["Ann", "Bob", "Chuck", "Dana"];

which name is at names[2]?

a)

Ann

b)

Bob

c)

Chuck

d)

Dana

90.

given

var nums = [3, 4, 6, 2, 9, 1];

what is

nums[1] + nums[3]

a)

4

b)

5

c)

6

d)

9

91.

given the list

var names = ["Ann", "Bob", "Chuck", "Dana"];

how would I replace "Bob" with "Bill"?

a)

names["Bob"] = "Bill";

b)

list[1] = "Bill";

c)

names[1] = "Bill";

d)

names[2] = "Bill";

92.

What would be the output of the following code?


var myList = ["A", "B", "C"];

console.log(myList.length);

a)

2

b)

3

c)

4

93.

If I had a list in my program called todo. While running lots of items are added to the end of the list. How can I get the last item in the list.

a)

todo[last]

b)

todo[todo.length]

c)

todo.length - 1

d)

todo[todo.length - 1]

94.

what is in myNumbers after the following code runs.

var myNumbers = [10,20,25];

myNumbers[0] = 5;

myNumbers[2] = 30;

a)

[10,20,25]

b)

[5,20,25]

c)

[5,20,30]

d)

[5,10,20,25,30]

95.

var myStuff = [20, “hat”, “pow”, 5];      
myStuff[1] = “cat”;                                  
myStuff[2] = myStuff[1];                       
myStuff[0] = myStuff[3] + 10;              
myStuff[3] = myStuff[0] + myStuff[0];

a)

["cat10", “hat”, “cat10cat10”, 5]

b)

[15, “cat”, “hat”, 40]

c)

[15, “cat”, “cat”, 30]

d)

[15, “hat”, “pow”, 30]

96.

var i = 1;

var nums = [3,2,1,5];

var x = (nums[ i + 1]) + (nums[i] + 1);

What is the value of x?

(a)  

97.
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)
98.
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);
99.
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
100.

___ is used for assigning values to a variable, ___ is used for comparing two variables

a)

=, !=

b)

=, ==

c)

==, =

d)

!=, ==