Mini game 1 + 2 = 3 (now with less time)
2026-07-04
A few years ago I ported a tiny game involving sums and differences of 1, 2 and 3 from JS to Elm.
Back then I subscribed to Time.every events to implement a countdown. Now I updated it to not need the elm/time package:
After the css animation countdown is finished, the code now listens to the animationend event, which is considered baseline widely available since 2019.
Html.Events.on "animationend" (Json.Decode.succeed Timeout)I like this approach because I no longer need to make sure that the CSS animation has the same duration as my timeout in Elm. And I only need to tweak one file to make such a behavior change.
Fewer options to make mistakes is why I like writing programs in a statically typed functional language.
About the game: You can use either mouse, fingers, or the keyboard to enter the correct values and try to get as high a score as possible.
If this iframe is not displayed, try the game directly or open it on ellie.
Other differences to last time (than time 😉)
Just replacing the periodic time subscription with the animationend event would have been boring, so I made more changes.

Debugging in Elm is quite nice with the time-traveling debugger.