Variables
Conditional
Functions
Debugging
Mixed Section
100

What are variables used for in a program?

To store information that can be used or changed later

100

What keyword starts a conditional statement?

if

100

What is a function?

A block of code designed to perform a specific task.

100

What is debugging?

Finding and fixing errors in your code.

100

What type of data can variables store?

Numbers, strings, booleans, etc.

200

What keyword is used to create a variable in App Lab?

var

200

What does == mean in an if statement?

It checks if two values are equal.

200

What keyword defines a function in App Lab?

function

200

What is a syntax error?

A mistake in the code that breaks the language rules.

200

What will print?
var word = "hi"; console.log(word + " there");

"hi there"

300

What is the value of x after this code runs?
 var x = 5; x = x + 2;

7

300

What is the output?
var num = 10; if (num > 5) { console.log("Big"); } else { console.log("Small"); }

Big

300

What is the difference between calling and defining a function?

Defining creates it; calling runs it.

300

What is a logic error?

Code runs but gives the wrong result.

300

What does return do inside a function?

Sends a value back to where the function was called.

400

What’s the difference between a variable’s name and its value?

The name is the label; the value is the data stored inside.

400

What’s the difference between == and =?

== checks equality; = assigns a value.

400

What’s wrong with this code?
function sayHi { console.log("Hi"); }

Missing parentheses — should be function sayHi() { ... }

400

What’s the first step in debugging?

Recreate or locate the problem.

400

What are the possible values of a Boolean variable?

true or false

500

What's the difference between a global variable and a local variable?

Global is defined outside of the onEvent and functions and can be used anywhere in the code.

Local variables are defined inside the OnEvent and function and can only be used inside that OnEvent or function.

500

Write an if-else statement that prints “Even” if x is even and “Odd” otherwise.

if (x % 2 == 0) { console.log("Even"); } else { console.log("Odd"); }

500

Write a function named add that returns the sum of two numbers a and b.

function add(a, b) { return a + b; }

500

Why might if (x = 5) cause a bug?

It assigns instead of compares — should use ==.

500

Write a function that prints “Hello” if name is “Alex”, otherwise prints “Who are you?”

function greet(name) { if (name == "Alex") { console.log("Hello"); } else { console.log("Who are you?"); } }