What are variables used for in a program?
To store information that can be used or changed later
What keyword starts a conditional statement?
if
What is a function?
A block of code designed to perform a specific task.
What is debugging?
Finding and fixing errors in your code.
What type of data can variables store?
Numbers, strings, booleans, etc.
What keyword is used to create a variable in App Lab?
var
What does == mean in an if statement?
It checks if two values are equal.
What keyword defines a function in App Lab?
function
What is a syntax error?
A mistake in the code that breaks the language rules.
What will print?
var word = "hi"; console.log(word + " there");
"hi there"
What is the value of x after this code runs?
var x = 5; x = x + 2;
7
What is the output?
var num = 10; if (num > 5) { console.log("Big"); } else { console.log("Small"); }
Big
What is the difference between calling and defining a function?
Defining creates it; calling runs it.
What is a logic error?
Code runs but gives the wrong result.
What does return do inside a function?
Sends a value back to where the function was called.
What’s the difference between a variable’s name and its value?
The name is the label; the value is the data stored inside.
What’s the difference between == and =?
== checks equality; = assigns a value.
What’s wrong with this code?
function sayHi { console.log("Hi"); }
Missing parentheses — should be function sayHi() { ... }
What’s the first step in debugging?
Recreate or locate the problem.
What are the possible values of a Boolean variable?
true or false
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.
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"); }
Write a function named add that returns the sum of two numbers a and b.
function add(a, b) { return a + b; }
Why might if (x = 5) cause a bug?
It assigns instead of compares — should use ==.
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?"); } }