For Loop: How to insert IF statement

Hi Everyone,

I am writing in to get some help on a exercise I have looked into several times, but dont seem to get it right.

We’ve already declared a variable for you in the editor called number to which the value 42 was assigned.
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.

This is what I thought would work out

var number = 42; 

for(var i=42;i<=50;i++); {   
    if (i/3 ===1) {
} else if (i/3 !== 1); {

BUT - I keep getting this error: You should have an if statement to check if each value of the variable i is a multiple of 3

Why? And how can i fixe this?


Why are you comparing i/3 to 1? That will not help you determine if i is a multiple of 3.

1 Like

I agree. It doesnt make sense, as this could only work if i were 3, which is not possible in this case.