Actually something like this would probably be better, but I still need to test it.
distance:(n, dp) => { if (dp === undefined) { var miles = n / 1609.34; dp = miles < 10 ? 1 : 0; } return n < 152.4 ? round(n * 3.28084) + "ft" : round(n / 1609.34, dp) + "mi"; },
@stweedo started
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
Actually something like this would probably be better, but I still need to test it.