I have added a round function to my code libs to round numbers to a certain number of decimals. It looks roughly as follows;
const round = (numberToRound,decimalPlaces = 2) => (e => Math.round(numberToRound * e) / e)(Math.pow(10,decimalPlaces ));
round(6800971.33999999985) = 6800971.34
If I run this code on the bangle emulator or the bangle2 watch directly I get "NaN" returned.
It breaks because Espruino doesn't support default parameter values, round(6800971.33999999985, 2) works though.
Thanks - it is slightly concerning that it doesn't cause an error though.
It seems that in Espruino, a=3 actually returned a reference to a when really it should have returned 3. So (a=2)=3 was possible when it shouldn't be according to the spec - I've just fixed this for cutting edge builds.
The main concern is as Gordon says, not that it isn't supported, but that no error is fired.
You got that link right here https://forum.espruino.com/conversations/388506/#17058616 when you asked :-)
:) yes - literally second line.
Also, if you give us some idea of what search words you'd likely search for on the Espruino site to find the info then I can add those to the keywords list for the page so it comes up for more people.
Same for any page really - I pretty much never get any PRs for this, but if there's a page that you found that didn't come up when you searched, there's a link at the bottom of the page that goes to GitHub (eg https://github.com/espruino/EspruinoDocs/blob/master/info/Features.md) and you can add to the KEYWORDS list at the top of the file and do a PR
yeh, my mistake. Clearly I am terrible at reading!
Don't worry about formatting, just type in the text and we'll take care of making sense of it. We will auto-convert links, and if you put asterisks around words we will make them bold.
For a full reference visit the Markdown syntax.
© Espruino, powered by microcosm.
Report a problem