WorksheetsCS&A Unit 4
Total questions: 33
Worksheet time: 22mins
What is the keyword to create a variable in Javascript?
(a)
What is the correct variable for a String?
var name = "Hank"
var name = 4
var name = true
var name = Hank
What is the correct variable for a Number?
var name = "Hank"
var name = 4
var name = true
var name = Hank
What is the correct variable for a Boolean?
var name = "Hank"
var name = 4
var name = true
var name = Hank
What is the correct definition for variable?
a named reference to a value that can be used repeatedly throughout a program.
a data type that is either true or false.
allows a program to change the value represented by a variable
a combination of operators and values that evaluates to a single value
What is concatenate?
when a cat is very annoying
want to combine Strings with other Strings, numbers, or even another variable. Glue them together
Answer to a conditional statement
when you concentrate really hard.
What is the correct definition for conditional statement?
a named reference to a value that can be used repeatedly throughout a program.
a data type that is either true or false.
affect the sequential flow of control by executing different statements based on the value of a Boolean expression.
a combination of operators and values that evaluates to a single value
How many times is a function defined?
0
1
never
as many times as you like
How many times is a function called?
0
1
never
as many times as you like
What text will be output by the program?
"Not so hot. Try again!"
"You are halfway there"
"So close!"
"You did it! Well done!"
What will be output by the console.log command on line 26?
50
500
1000
100
What number will be output by the console.log command on line 6?
15
25
20
17
What will be output by the console.log command on line 11?
6
5
9
14
What will be output by the console.log command on line 18?
15
30
45
50
What text will be output by the program?
"one"
"two"
"three"
"four"
What will be the order of the numbers printed to the console when this program is run?
844
844
12
12
12
844
12
12
You get a discount! never displays. What change would fix this issue?
Var age should be set to 0
setText should be getText
Remove var from line 63
remove var from line 61
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?
it works as intended
num1>num2
&&
num 2<num1
num 2<num1
||
num1>num2
num2 == num1
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?
lines 86-90
lines 93-97
lines 87-90
&
84-97
there are no repeated lines
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.
day==Saturday &&
day ==Sunday
&&
age<=18
day==Saturday
|| Sunday
||
price<=18
day==Saturday ||
day ==Sunday
&&
age<=18
day==Saturday
&&
day==Sunday
||
age>=18
Circle the function definition. Place an X over the function call.
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.
What will the value of napkins be at the end of the flowchart below?
napkins = 1
napkins = 2
napkins = 3
napkins = 4
Complete the truth table for logical AND (&&)
1. false
2. true
3. true
4. true
1. false
2. false
3. true
4. true
1. false
2. true
3. true
4. false
1. true
2. false
3. false
4. false
Complete the truth table for logical OR (||)
1. false
2. true
3. true
4. true
1. false
2. false
3. true
4. true
1. true
2. true
3. true
4. false
1. true
2. false
3. false
4. false
What is the difference between a single equal sign ( = ) and the double equal sign ( == )?
Nothing
single sign means equal to
The assignment operator (=) assigns value to a variable
The double equal sign is used to compare values to see if one is equal to another value.
What is the name for the % operator
Percentage
Percent
divisible
MOD operator
What does the MOD operator (%) return?
the percent
the average
The remainder of a division problem
the answer
Evaluate the following:
12%3
4
3
9
0
Evaluate the following:
13%5
2
3
8
0
Evaluate the following:
7%20
0
2
7
20
What is the number 1 hint Ms. Mieras told you about using the MOD operator?
Not this answer
If the first number is smaller ex. 12%20
it will always return the first number
not this answer
try again
What is the difference between local and global variables?
global variables are temporary and used anywhere; local is permanent and can only be used where they are created
there is no difference
global variables are permanent and used anywhere; local is temporary and can only be used where they are created
we almost always use local variables
