← Back to all posts
Javascript support

Unfortuntely am stuck with the printing part of a challenge I have no idea where am going wrong it requires a loop and too display the numbers going up in 3s up to 20 but i cant figure out what am doing wrong ive spent two days doing it and slowly losing hope. If anyone can help that would great.

function returnMultiplesOf3()
{
var test = "work";
let i = 3;
for (i = 0; i < 20; i++)
if (i % 3 ===20) {
continue;
}
}

returnMultiplesOf3();
console.log(returnMultiplesOf3());

tomod24 (0)

yeah so it basically should be going from 1-20 and disaplying mutiples of 3 in the output

Coder100 (12439)

Hi! Right now your code is:

``````function returnMultiplesOf3()
{
var test = "work";
let i = 3;
for (i = 0; i < 20; i++)
if (i % 3 ===20) {
continue;
}
}

returnMultiplesOf3();
console.log(returnMultiplesOf3());``````

But honestly, that doesn't do anything. It doesn't have a return value, and all you are saying is, `if the current number is divisible by 3, continue`. But it continues even if it is not.

Try this:

``````function returnMultiplesOf3()
{
var test = "work";
let i = 3;
for (i = 0; i < 20; i+= 3)
console.log(i)
}

returnMultiplesOf3();
console.log(returnMultiplesOf3());``````

Now, `i` skips by 3s until it gets up to 20 (but the highest it will go is 18 because 21 is bigger than 20)

tomod24 (0)

@Coder100 thats nearly it but just needs to be 3 6 9 12 15 18 mine wasnt disaplaying anything and i didnt know why

tomod24 (0)

@Coder100 really i get duplicate answers on mine any idea why

Coder100 (12439)

yeah, thats because you are calling it twice. @tomod24

tomod24 (0)

@Coder100 Hi thats what am asking where am calling it twice for it to be happening i have the same code as you

[deleted]

All it's doing now is printing 'apple'???

tomod24 (0)

@GoofyGus not sure if i posted the right thing sorry did you read the comment above

tomod24 (0)

@GoofyGus my fault there thanks for trying to help though

[deleted]

Oh, ok @tomod24