64

// during testing, fortunately!

addresses = [
'user1@blah.com',
...
]

x=0

while ( x < addresses.length ) {
toEmail = addresses[x]
sendEmail ( toEmail )
// forget to increment x
}

// user1 not too happy

Comments
  • 2
    Foreach? No need to increment then.
  • 4
    @hexacore I agree. Wasn't my code. I'm also pleased to report that I wasn't user1, who received close to 100 emails.
  • 2
    Stuff like that should be done with a for loop, then bugs like this will not occur :)
  • 0
    personally i prefer avoiding while and classic for loops when iterating through an array: async.map, array.foreach, for x in array just to name a few
Add Comment