Latest Update Graded A+
Can you use a loop inside another loop?
✔✔ Yes, this is called a nested loop.
How do you execute a block of code at least once before checking a condition?
✔✔ By using a `do...while` loop.
What is the main difference between a `do...while` loop and a `while` loop?
✔✔ A `do...while` loop executes at least once before checking the condition, while a `while`
loop checks the condition first.
How do you combine multiple conditions in an `if` statement?
✔✔ Using logical operators like `&&` (AND) and `||` (OR).
How do you stop a function from executing further?
✔✔ By using the `return` statement.
1
, What is short-circuit evaluation in JavaScript?
✔✔ It is when logical operators stop evaluating as soon as the result is determined.
What happens if a `return` statement is used in a loop?
✔✔ It immediately exits the function containing the loop.
Can a `switch` statement work with string values?
✔✔ Yes, a `switch` statement can compare string values.
How do you prevent a loop from running forever?
✔✔ By ensuring the loop condition eventually becomes false.
How can you iterate through an array without using a loop?
✔✔ By using array methods like `.forEach()`, `.map()`, or `.reduce()`.
What happens if you use `break` inside an `if` statement within a loop?
✔✔ It stops the loop entirely if the condition inside `if` is met.
2