What keyword should you use for a variable that will never be reassigned?
const
What property tells you the number of characters in a string?
.length
What keyword is used to define a function in JavaScript?
function
What keyword starts a conditional statement in JavaScript?
if
Which comparison operator checks both value and type?
===
Give one valid JavaScript variable name that follows camel case rules.
myVariableName
Which method checks if a string starts with certain text?
.startsWith()
What are values placed inside a function’s parentheses when calling it called?
Arguments
Which statement is best for checking one value against many fixed options?
switch statement
What does true && false evaluate to?
false
What does the += operator do to a variable’s value?
Adds to its current value.
What is the difference between .substring() and .slice()?
.slice() allows negative indexes; .substring() does not.
What does the return keyword do in a function?
Sends a value back to where the function was called.
What does the ternary operator (? :) do?
Acts as a shorthand for if/else in assignments
Which logical operator returns true if at least one condition is true?
|| (OR)
Which characters are allowed in JavaScript variable names (excluding the first character rule)?
Letters, numbers, _, and $
What will "Hello" + 5 return in JavaScript?
"Hello5" (string concatenation)
What is the difference between local and global variables?
Local variables exist only inside a function; global variables are accessible anywhere.
What is the result of isNaN("Hello")?
true
What is the result of 5 != "5" in JavaScript?
false
What happens if you try to use a variable that has been declared but not assigned a value?
It has the value undefined.
What method would you use to find the position of "cat" in "The cat sat"?
.indexOf("cat")
Write a function header for a function named add that takes two parameters, x and y.
function add(x, y) { }
Write a simple if statement that checks if score is greater than or equal to 90.
if (score >= 90) {
// code
}
What does the ! operator do to a Boolean value?
Reverses it (true becomes false, false becomes true).