What is the capital city of France?
Paris
What is the scope of a variable declared inside a function?
Local Scope
What is the syntax of a basic if statement in JavaScript?
if (condition) {
// code to execute if condition is true
}
What is a loop in JavaScript?
A loop is a control structure that repeatedly executes a block of code as long as a specified condition is true.
What is a function?
A reusable block of code that performs a specific task.
How many continents are there in the world?
Seven
What is the scope of a variable declared outside of any function?
Global Scope
let x = 10;
if (x > 5) {
console.log("Greater than 5");
} else {
console.log("Less than or equal to 5");
}
How do you write a basic for loop in JavaScript?
for () {
}
How do you define a function in JavaScript?
function functionName() {
// function body
}
What is the largest planet in our solar system?
Jupiter
Which keywords (2) should you use to declare a block-scoped variable in JavaScript?
let and const
How would you write an if-else statement that checks if a number is positive, negative, or zero?
if (num > 0) {
console.log("Positive");
} else if (num < 0) {
console.log("Negative");
} else {
console.log("Zero");
}
What will this loop output?
for (let i = 1; i <= 3; i++) {
console.log(i);
}
1
2
3
What will this code output?
function greet() {
return "Hello, World!";
}
console.log(greet());
"Hello, World!"
What is the chemical symbol for water?
H2O
Can you access a variable declared with var inside an if block from outside the block?
Yes, because var does not respect block scope.
What will this code print?
let age = 18;
if (age >= 18) {
console.log("Adult");
} else {
console.log("Minor");
}
"Adult"
How do you write a while loop that prints numbers 1 to 5?
let i = 1;
while (i <= 5) {
console.log(i);
i++;
}
What is a return statement in a function?
A return statement in a function specifies the value that the function will return when it is called.
Who wrote the play “Romeo and Juliet”?
William Shakespeare
What will happen if you try to access a variable declared with let inside a block, from outside the block?
It will throw an error, as let variables are block-scoped and not accessible outside the block.
What happens if the condition in an if statement is false and there is no else clause?
Nothing will happen; the code inside the if block will be skipped.
What will happen with this code and why?
let i = 0;
while (i < 3) {
console.log(i);
}
It will result in an infinite loop because i is never incremented inside the loop.
What happens if a function doesn’t have a return statement?
If a function doesn’t have a return statement, it will return undefined by default.
Or simply nothing gets returned as a value.