For loop , multiples of 3

hi the challenge is:

Use a for loop to go through all numbers from number up to 50 (both inclusive), and check if they are multiples of 3. If they are, print them.

// my code:

for(var number = 42; number <= 50; number ++)
    if(number % 3 === 0){
        console.log(number);
    }


am I doing wrong the seek for the multiple of 3? I don't see why?
tos
//   ↓ why start at 42?                   ↓ no space between number and ++
for (var number = 42; number <= 50; number++) { // I recommend always using {}s
  if (number % 3 === 0) { // This checks if 'number' is a multiple of 3
    console.log(number);
  }
} // closing for loop }

Hi there. I added a few comments to your code with some questions about what you are doing.


You may find it helpful to go through the freeCodeCamp curriculum on for loops, starting at this lesson

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