samuelmarina / is-even

Is a number even?

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

stop being slow asf, do millions of these in seconds

chirag350 opened this issue · comments

const fs = require('fs');
var converter = require('number-to-words');
let currentNumber = 1; // Replace with that 

while (true) {
    currentNumber++;
    const noinwords = converter.toWords(currentNumber).replace(",", "");
    const nointitlecase = toTitleCase(noinwords);
    const noinuppercase = noinwords.toUpperCase();
    function isEven(n) {
        return n % 2 == 0;
     }
    const eOrO = isEven(currentNumber)
    const endresult = `else if(number === ${currentNumber} || number === "${currentNumber}" || number === "${noinwords}" || number === "${nointitlecase}" || number === "${noinuppercase}") return ${eOrO};\n`
    fs.appendFileSync('./index.js', endresult)
};

function toTitleCase(str) {
    return str.replace(
      /\w\S*/g,
      function(txt) {
        return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
      }
    );
  }

this thing does millions of numbers in seconds.
run this script seperately

commented

We understand your concern with efficiency. However, that code might break in eventual updates that the framework is a target of. And besides, it's very unreliable. What if my computer does not have a CPU? Or a BIOS battery?!

Thank you for understanding.

We understand your concern with efficiency. However, that code might break in eventual updates that the framework is a target of. And besides, it's very unreliable. What if my computer does not have a CPU? Or a BIOS battery?!

Thank you for understanding.

Ok but why are you running JS in a BIOS

We understand your concern with efficiency. However, that code might break in eventual updates that the framework is a target of. And besides, it's very unreliable. What if my computer does not have a CPU? Or a BIOS battery?!
Thank you for understanding.

Ok but why are you running JS in a BIOS

Why aren't you running JS in your BIOS?