Random Facts
Variables
If Statements
Loops
Functions
100

What is the capital city of France?

Paris

100

What is the scope of a variable declared inside a function?

Local Scope

100

What is the syntax of a basic if statement in JavaScript?

if (condition) {

  // code to execute if condition is true

}

100

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.

100

What is a function?

A reusable block of code that performs a specific task.

200

How many continents are there in the world?

Seven

200

What is the scope of a variable declared outside of any function?

Global Scope

200

let x = 10;

if (x > 5) {

  console.log("Greater than 5");

} else {

  console.log("Less than or equal to 5");

}

"Greater than 5"
200

How do you write a basic for loop in JavaScript?

for () {

}

200

How do you define a function in JavaScript?

function functionName() {

  // function body

}

300

What is the largest planet in our solar system?

Jupiter

300

Which keywords (2) should you use to declare a block-scoped variable in JavaScript?

let and const

300

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");

}

300

What will this loop output?

for (let i = 1; i <= 3; i++) {

  console.log(i);

}

1

2

3

300

What will this code output?

function greet() {

  return "Hello, World!";

}

console.log(greet());

"Hello, World!"

400

What is the chemical symbol for water?

H2O

400

Can you access a variable declared with var inside an if block from outside the block?

Yes, because var does not respect block scope.

400

What will this code print?

let age = 18;

if (age >= 18) {

  console.log("Adult");

} else {

  console.log("Minor");

}

"Adult"

400

How do you write a while loop that prints numbers 1 to 5?

let i = 1;

while (i <= 5) {

  console.log(i);

  i++;

}

400

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.

500

Who wrote the play “Romeo and Juliet”?

William Shakespeare

500

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.

500

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.

500

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.

500

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.