Created
June 27, 2020 18:38
-
-
Save ruddha2001/70539e1a9b796f769e62d22854669180 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Allow only positive numbers, throw error for negative ones | |
* @param {number} num - Number to test | |
*/ | |
export const checkNumber = async (num: number) => { | |
if (num >= 0) return "You are good to go"; | |
throw Error("Negative numbers are not accepted"); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment