• Post author:
  • Post category:Blog
  • Reading time:2 mins read
  • Post last modified:June 12, 2024

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.

For more Questions and Answers:

JavaScipt Essentials 1 (JSE) | JSE1 – Module 4 Test Exam Answers Full 100%

Subscribe
Notify of
guest
0 Comments
Newest
Oldest Most Voted
Inline Feedbacks
View all comments