samuelmarina / is-even

Is a number even?
1.85k stars 193 forks source link

stop being slow asf, do millions of these in seconds #193

Open chirag350 opened 3 years ago

chirag350 commented 3 years ago
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

AntonioOliveira2 commented 3 years ago

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.

andyman1222 commented 1 year ago

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

MagusWyvern commented 1 year ago

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?