0

I'm trying to implement this loop with Coffeescript

for( var i = arr.length; i--; )

Any ideas?

Foreign Object
  • 1,630
  • 11
  • 22
  • 1
    I don't know any coffescript but aren't you supposed to have some kind of exit condition to that loop ? And what is actually your problem ? – Laurent S. Jul 02 '14 at 16:52
  • 1
    @Bartdude The exit condition is `i--`. When that evaluates to a falsy value (ie, 0) the loop will exit. This is completely fine. The problem is that that loop is a *JavaScript* loop, and he's trying to figure out how to write the equivalent CoffeeScript loop. – user229044 Jul 02 '14 at 16:54
  • @Bartdude The question is straightforward if you've done any work with Coffeescript. – Foreign Object Jul 02 '14 at 16:56
  • Well, I'll be a little less stupid when going to bed this evening. As I stated I don't know any coffeescript, but will have a look at it :-) – Laurent S. Jul 02 '14 at 16:59

1 Answers1

1
for i in [arr.length-1..0] by -1
    # Something!
Ry-
  • 218,210
  • 55
  • 464
  • 476