Skip to content

Latest commit

 

History

History
27 lines (21 loc) · 432 Bytes

check-if-a-number-is-positive.mdx

File metadata and controls

27 lines (21 loc) · 432 Bytes
category contributors created title updated
Validator
tugsanunlu
2020-05-07
Check if a number is positive
2021-10-13

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