In JavaScript, 0 % 100 is 0, but in Elm, the result of the same operation is this.
> remainderBy 0 100
NaN : Int
I have just thought remainderBy function better returns Maybe Int like below.
> remainderBy 0 100
Nothing : Maybe Int
> remainderBy 6 3
Just 2 : Maybe Int
Does Elm have any reason why remainderBy returns NaN?
The first argument for remainderBy is the divisor, the opposite of what you expected. So remainderBy 0 100 is the same as 100 % 0
You are dividing by 0, so the result is NaN.
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