Why is my variable not printing 1 and printing 11?

Hello, why is the ‘i’ printing 2 as start and finishing at 11 when the condition is this:

let i = 1,
while (i <= 10) {
    if (i === 1) {
    quantity = 'time';
  } else {
    quantity = 'times'
    console.log(`${txtsoobin.firstName} sang blue hour ${i} ${quantity}.`);

Step through the code line by line. Think about where your i++ is placed.

Most people would use a for loop for this.

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.