Examine the following code:
for (let a = 4; a < 4; a++) { console.log("test"); }
How many times will "test"
be displayed in the console as a result of its execution?
- 1
- 4
- 3
- It will not be displayed at all.
Explanation & Hint:
The for loop in the code initializes a with the value of 4. The loop condition a < 4 is evaluated before each iteration. Since a is already equal to 4, the loop condition is false, and the loop will not execute. Therefore, “test” will not be displayed in the console at all because the loop is not executed. |