GitHub 6521★

Check if a number is positive

JavaScript version

const isPositive = (n) => Math.sign(n) === 1;

TypeScript version

const isPositive = (n: number): boolean => Math.sign(n) === 1;

Examples

isPositive(3); // true
isPositive(-8); // false
Follow me on and to get more useful contents.