add type checking

This commit is contained in:
Suryapratap Singh
2021-08-31 13:48:39 +05:30
parent c67b0e9f1d
commit 92b8b46f36
2 changed files with 9 additions and 1 deletions

View File

@ -8,6 +8,10 @@
* @returns `Number` n reverse in reverse.
*/
const ReverseNumber = (number) => {
// firstly, check that input is a number or not.
if (typeof number !== 'number') {
return new TypeError('Argument is not a number.')
}
// A variable for storing the reversed number.
let reverseNumber = 0
// Iterate the process until getting the number is 0.