Created
June 27, 2020 17:05
-
-
Save ruddha2001/d581f37d484df14f38fc4c6ef509b09b 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 asyncThrowsError = 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