wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

CS&A Unit 4

Total questions: 33

Worksheet time: 22mins

Name
Class
Date
1.

What is the keyword to create a variable in Javascript?

(a)  

2.

What is the correct variable for a String?

a)

var name = "Hank"

b)

var name = 4

c)

var name = true

d)

var name = Hank

3.

What is the correct variable for a Number?

a)

var name = "Hank"

b)

var name = 4

c)

var name = true

d)

var name = Hank

4.

What is the correct variable for a Boolean?

a)

var name = "Hank"

b)

var name = 4

c)

var name = true

d)

var name = Hank

5.

What is the correct definition for variable?

a)

a named reference to a value that can be used repeatedly throughout a program. 

b)

a data type that is either true or false.

c)

allows a program to change the value represented by a variable 

d)

a combination of operators and values that evaluates to a single value 

6.

What is concatenate?

a)

when a cat is very annoying

b)

want to combine Strings with other Strings, numbers, or even another variable. Glue them together

c)

Answer to a conditional statement

d)

when you concentrate really hard.

7.

What is the correct definition for conditional statement?

a)

a named reference to a value that can be used repeatedly throughout a program. 

b)

a data type that is either true or false.

c)

affect the sequential flow of control by executing different statements based on the value of a Boolean expression.

d)

a combination of operators and values that evaluates to a single value 

8.

How many times is a function defined?

a)

0

b)

1

c)

never

d)

as many times as you like

9.

How many times is a function called?

a)

0

b)

1

c)

never

d)

as many times as you like

10.

What text will be output by the program?

a)

"Not so hot. Try again!"

b)

"You are halfway there"

c)

"So close!"

d)

"You did it! Well done!"

11.

What will be output by the console.log command on line 26?

a)

50

b)

500

c)

1000

d)

100

12.

What number will be output by the console.log command on line 6?

a)

15

b)

25

c)

20

d)

17

13.

What will be output by the console.log command on line 11?

a)

6

b)

5

c)

9

d)

14

14.

What will be output by the console.log command on line 18?

a)

15

b)

30

c)

45

d)

50

15.

What text will be output by the program?

a)

"one"

b)

"two"

c)

"three"

d)

"four"

16.

What will be the order of the numbers printed to the console when this program is run?

a)

844

b)

844

12

c)

12

12

d)

844

12

12

17.

You get a discount! never displays. What change would fix this issue?

a)

Var age should be set to 0

b)

setText should be getText

c)

Remove var from line 63

d)

remove var from line 61

18.

When the function largest is called, the code is meant to print the larger of the two numbers. Does the code work as intended? If not, what change could be made so that the code works as intended?

a)

it works as intended

b)

num1>num2

&&

num 2<num1

c)

num 2<num1

||

num1>num2

d)

num2 == num1

19.

There is repeated code in the onEvent blocks. Which lines of code should be added to an updateScreen function which would be called in each onEvent block?

a)

lines 86-90

b)

lines 93-97

c)

lines 87-90

&

84-97

d)

there are no repeated lines

20.

An art gallery charges different prices depending on the day of the week and the age of the visitor. The price rules are as follows: on Saturday and Sunday children under 18 get in free. For all other days and ages, the cost is $7. Write the conditional expression using logical operators that would correctly decide the price.

a)

day==Saturday &&

day ==Sunday

&&

age<=18

b)

day==Saturday

|| Sunday

||

price<=18

c)

day==Saturday ||

day ==Sunday

&&

age<=18

d)

day==Saturday

&&

day==Sunday

||

age>=18

21.

Circle the function definition. Place an X over the function call.

22.

A person must meet certain age requirements to view G, PG-13, and R rated movies. See the chart below. Write the code that would properly display whether a person can see a particular move based on its rating.

a)
b)
c)
d)
23.

What will the value of napkins be at the end of the flowchart below?

a)

napkins = 1

b)

napkins = 2

c)

napkins = 3

d)

napkins = 4

24.

Complete the truth table for logical AND (&&)

a)

1. false

2. true

3. true

4. true

b)

1. false

2. false

3. true

4. true

c)

1. false

2. true

3. true

4. false

d)

1. true

2. false

3. false

4. false

25.

Complete the truth table for logical OR (||)

a)

1. false

2. true

3. true

4. true

b)

1. false

2. false

3. true

4. true

c)

1. true

2. true

3. true

4. false

d)

1. true

2. false

3. false

4. false

26.

What is the difference between a single equal sign ( = ) and the double equal sign ( == )?

a)

Nothing

b)

single sign means equal to

c)

The assignment operator (=) assigns value to a variable

d)

The double equal sign is used to compare values to see if one is equal to another value.

27.

What is the name for the % operator

a)

Percentage

b)

Percent

c)

divisible

d)

MOD operator

28.

What does the MOD operator (%) return?

a)

the percent

b)

the average

c)

The remainder of a division problem

d)

the answer

29.

Evaluate the following:

12%3

a)

4

b)

3

c)

9

d)

0

30.

Evaluate the following:

13%5

a)

2

b)

3

c)

8

d)

0

31.

Evaluate the following:

7%20

a)

0

b)

2

c)

7

d)

20

32.

What is the number 1 hint Ms. Mieras told you about using the MOD operator?

a)

Not this answer

b)

If the first number is smaller ex. 12%20

it will always return the first number

c)

not this answer

d)

try again

33.

What is the difference between local and global variables?

a)

global variables are temporary and used anywhere; local is permanent and can only be used where they are created

b)

there is no difference

c)

global variables are permanent and used anywhere; local is temporary and can only be used where they are created

d)

we almost always use local variables