Skip to content

Instantly share code, notes, and snippets.

@ruddha2001
Created June 27, 2020 18:38
Show Gist options
  • Save ruddha2001/70539e1a9b796f769e62d22854669180 to your computer and use it in GitHub Desktop.
Save ruddha2001/70539e1a9b796f769e62d22854669180 to your computer and use it in GitHub Desktop.
/**
* 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