Variables
Boolean Conditions
if...Else...if
Functions
Vocabulary
100

How would you create a variable called days and set it equal to 7?

var days = 7;

100

Is this code okay to use?  If not, say why.

if ( teacher == "Mrs. Q" && period == 3 || 4 )
   console.log("You are in AP CSP");

No.

Should say period==3 || period==4

100

What is output from this code if age is 15?

if ( age==16 )
  console.log("You can drive!")

nothing

100

Name one reason for creating a function.

1) Naming a section of repeated code for reuse

2) Shortening your lines of code by reusing code

3) Easier to debug/edit when repeated code is encapsulated in one place

100

What is the assignment operator?

=

200

What's wrong with this code?

Variable score is initialized twice.  Every time button2 is clicked, score is re-created, so it will never reach greater than 5.

200

I want to find the larger number between num1 and num2.  What would replace missing code?

if ( <missing code> ) {
   console.log( "num1 is bigger" );
else
   console.log( "num2 is bigger" );

num1 > num2

200

What will be output from this code if you have 0 points?

if ( points > 0 ) {
    console.log( "Keep Playing!" );
else
    console.log( "Game Over" );

Game Over

200

You have a yellow triangle next to your code below.  Why?

function myFunction() {

//lots of commands in here

}

You declared your function, but never called it.

200

What is the comparison operator for equality?

==

300

Naomi is trying to update the score of her game by 2 points.  Here is her code.  What is her mistake?

var score = 0;
score = 2;

Should be

score = score + 2;

300

I want to see if I qualify for the Sunday Student Discount.  You get the discount if you're under 18 and if it's Sunday.  What would be the Boolean condition?

My variables are age & day.

day == "Sunday" && age < 18

300

if ( age >= 65 )
    console.log( "Senior Discount" );
else if ( age < 18 )
    console.log( "Student Discount" );
else
    console.log( "Regular Price" );

What is output if you are 18 years old?

Regular Price

300

Can you declare a function inside another function declaration?

No

300

What is the comparison operator for not equal?

!=

400

Cynthia is receiving an error.  What is wrong with this code?

var points;
points = points + 1;

points is never initialized

400

Name a situation where this would be true.

( day == "Saturday" || day == "Sunday" ) && ( age < 18 )

If it's Saturday, and I'm 12 years old...then this situation would be true.

400

Find the error in logic.

if ( time > 12 )
    console.log( "Afternoon" );
else if ( time > 22 )
    console.log( "Bedtime" );
else
    console.log( "Morning" );

The 2nd condition will never be done.

400

Can you call a function inside another function declaration?

Yes

400

What is it called when strings are added or "glued" together?

Concatenation

M
e
n
u