UNPKG

@shubham_yadav/mypackage

Version:

This is my first package ,created during class

25 lines (23 loc) 468 B
let otp="" function generateOTP(len){ try { otp = "" for(let i=0;i<len;i++){ otp += Math.floor(Math.random()*10); } return otp; } catch (error) { throw error; } } function verifyOtp(userOtp){ try{ if(otp==userOtp){ return true; } throw new Error("otp not matched")//custom error }catch (error) { throw error; } } modules.exports = {generateOtp,verifyOtp}