Add the good


#1

can't print 'FillBuzz' What's wrong
for(var i = 1; i < 21; i++){
if(i % 3 == 0){
console.log('Fizz')
}
else if( i % 5 == 0){
console.log('Buzz')
}
else if((i % 3 == 0) && (i % 5 == 0) ){
console.log('FizzBuzz')
}
else if (i % 3 !== 0 && i % 5!== 0){
console.log(i)
}
}


#2

this cause is statement levels. it's so interesting. attention plz

i = 15
if i % 3 == 0 --> true
then run console.log('Fizz')
and the other statement not check because this statement is top and return true

for solve this you must change the position of bellow statement to top of them.

if((i % 3 == 0) && (i % 5 == 0)) {
    ...
}

in always you must attention to priority and position of your statement


#3

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