print numbers between 1- 20 using rules

后端 未结 10 1856
不思量自难忘°
不思量自难忘° 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:30

    Try walking through the logic by hand. If i is 1, then only the last block works. If i is 3, the first block works. If i is 5, the second block works. And if i is 15, the second block works, and the third never gets a chance.

    In general, have the most restrictive conditions run before the least restrictive. You should also notice and check carefully when two of your blocks are dissimilar. You have four blocks, and only one is an else block.

提交回复
热议问题