print numbers between 1- 20 using rules

后端 未结 10 1844
不思量自难忘°
不思量自难忘° 2020-12-11 09:45

I am going through codeacademys JavaScript tutorials as i am new to it. The tutorial asks for the following:

Print out the numbers from 1 - 20.
The rules:

10条回答
  •  春和景丽
    2020-12-11 10:10

    You should check if a number is divisible by both 3 and 5 in your first IF, since numbers that are divisible by both would otherwise result in the first and the second IF statement being executed.

    Furthermore, the rules tell you to write out "FizzBuzz" in case a number is divisible by both, and at the moment you're only printing out "Buzz".

提交回复
热议问题