Questions and Answers Graded A+
What will be the output of the following code?
```js
let x = 5;
if (x > 3) {
console.log("Hello");
} else {
console.log("Goodbye");
}
```
A) Goodbye
B) Nothing
✔✔ C) Hello
D) Error
Which loop is best when the number of iterations is known?
A) while
1
,✔✔ B) for
C) do...while
D) switch
What does the `break` statement do in a loop?
A) Skips to the next iteration
✔✔ B) Exits the loop immediately
C) Repeats the current iteration
D) Throws an error
What is the purpose of a `continue` statement?
✔✔ A) Skips the current iteration and moves to the next
B) Exits the loop
C) Pauses the loop
D) Restarts the loop
Which keyword is used to define a condition in JavaScript?
✔✔ A) if
2
, B) loop
C) switch
D) case
How many times will this loop run?
```js
for (let i = 0; i < 5; i++) {
console.log(i);
}
```
✔✔ A) 5
B) 4
C) Infinite
D) 0
What will be the result of the following statement?
```js
console.log(5 > 3 && 2 < 1);
3