Jump in the discussion.

No email address required.

Idk shit about coding but do you really need 12 files to do something like this?

:marseyconfused:

Jump in the discussion.

No email address required.

node.js devs will borrow everyone else's code and pretend they know how to code

Jump in the discussion.

No email address required.

No but JS devs are braindead r-slurs

:#marseygigaretard:

Jump in the discussion.

No email address required.

Well paid braindead r-slurs thank you very much

Jump in the discussion.

No email address required.

JS devs should be executed and JS should be thrown in the fire with their bodies

Jump in the discussion.

No email address required.

You don't, but if someone else puts up a repo that does it in 12 files then it's quicker and easier to use that than write your own code

Jump in the discussion.

No email address required.

Is it really faster than writing n % 2 === 1?

Jump in the discussion.

No email address required.

No but it's easier because you don't actually need to know how code works

Jump in the discussion.

No email address required.

yes. I've tested it in production.

Jump in the discussion.

No email address required.

excuse me sir, you missed some edge cases which is why is-odd exists.

const isNumber = require('is-number');

module.exports = function isOdd(value) {

 const n = Math.abs(value);

 if (!isNumber(n)) {

   throw new TypeError('expected a number');

 }

 if (!Number.isInteger(n)) {

   throw new Error('expected an integer');

 }

 if (!Number.isSafeInteger(n)) {

   throw new Error('value exceeds maximum safe integer');

 }

 return (n % 2) === 1;

};

Jump in the discussion.

No email address required.

Stupid, maybe you should know what type n is.

Jump in the discussion.

No email address required.

Welcome to JavaScript

Jump in the discussion.

No email address required.

Link copied to clipboard
Action successful!
Error, please refresh the page and try again.