3 and good. Help please


#1

for (var i=0; i<=20; i++)
{
if((i % 3 === 0) && (i % 5 === 0)){
console.log("FizzBuzz");
}elseif(i % 5 === 0){
console.log("Buzz");
}elseif(i % 3 === 0){
console.log("Fizz");
}else{
console.log("not divisible with any number");
}
}

it gives suntax error "unexpected token {"


#2

i figured out that elseif was wrong. after correction now i am having msg that wrong number of items are given

or (var i=0; i<=20; i++)
{
console.log(i);
if((i % 3 === 0) && (i % 5 === 0)){
console.log("FizzBuzz");
}else if(i % 5 === 0){
console.log("Buzz");
}else if(i % 3 === 0){
console.log("Fizz");
}else{
console.log("not divisible with any number");
}
}

output:
Oops, try again. It looks like you printed out the wrong number of items.

0
FizzBuzz
1
not divisible with any number
2
not divisible with any number
3
Fizz
4
not divisible with any number
5
Buzz
6
Fizz
7
not divisible with any number
8
not divisible with any number
9
Fizz
10
Buzz
11
not divisible with any number
12
Fizz
13
not divisible with any number
14
not divisible with any number
15
FizzBuzz
16
not divisible with any number
17
not divisible with any number
18
Fizz
19
not divisible with any number
20
Buzz


#3

Try change for() condition:

for (var i = 1; i <= 20; i++) {
...
}

#4

at the top of your code you need to delete console.log(i);

and then at the bottom in the last else section change the console log to just i and not the string


#5

You have to change the

for( i = 0; i < 20; i++)

to

for( i = 1; i < 20; i++)


#6

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