I am trying to convert some apple chart examples from javascript to coffeescript. Having a tough time trying to figure out how to write this for loop in coffee script. Thanks for any help in advance
for (scale = maxVal; scale >= 0; scale -= stepSize) {...}
scale = maxVal
while scale >= 0
...
scale -= stepSize
There's a good tool for converting JS to Coffeescript: http://js2.coffee/
This loop will increment by the negative of stepSize.
maxVal = 10
stepSize = 1
for scale in [maxVal..0] by -stepSize
console.log scale
However, if stepSize is actually 1, then
maxVal = 10
for scale in [maxVal..0]
console.log scale
would produce the same result
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With