Multiple conditions in for loop

前端 未结 2 1318
失恋的感觉
失恋的感觉 2020-12-19 01:52

How can I write a for loop with multiple conditions?

Intended Javascript:

for(k=1; k < 120 && myThing.someValue > 1234; k++){
  myThing         


        
2条回答
  •  感情败类
    2020-12-19 02:51

    Since a for loop is equivalent to a while loop plus a couple of statements, and CoffeeScript offers only one kind of for loop, use a while loop. If you’re trying to get specific JavaScript output, you should probably not be using CoffeeScript.

    Of course, there is always

    `for(k=1; k < 120 && myThing.someValue > 1234; k++) {`
    do myThing.action
    `}`
    

    Avoid.

提交回复
热议问题