Function isInteger not found

Posted on
  • I ran into an issue where I cannot access a method of Number called isInteger..

    if (!(Number.isInteger(schedule[letter][day][event]["Duration"]))) throw "Validation failed";
    

    Running the following code returns Uncaught Error: Function "isInteger" not found!::

    console.log(Number.isInteger(1));
    

    How can I install the Number class into my Bangle.js? Is there any way to fix this?

  • I'm afraid Number.isInteger isn't in Espruino, but you can fake it with this I believe:

    Number.isInteger = it => isFinite(it) && Math.floor(it) === it;
    
  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

Function isInteger not found

Posted by Avatar for Asynchronous @Asynchronous

Actions