Given the code: for (let i = 1; i < 5; i += 2) { console.log(i); }, what will be the output?
Understand the Problem
The question is asking what the output of the given JavaScript code will be when executed. The code includes a loop that iterates with a specific increment.
Answer
1 and 3 each on a new line.
The final answer is that the console will display 1 and 3 each on a new line.
Answer for screen readers
The final answer is that the console will display 1 and 3 each on a new line.
More Information
The loop starts at 1, increments i by 2, thus going to values 1 and 3, and stops once i becomes 5 which is not less than 5.
Tips
A common mistake is incrementing the loop incorrectly or misunderstanding the loop condition logic. Ensure the increment and condition match the loop function's intended iterations.
AI-generated content may contain errors. Please verify critical information