function generateOTP(length) { const digits = '0123456789'; let otp = ''; otp += digits[Math.floor(Math.random() * 9) + 1]; // first digit cannot be zero for (let i = 1; i < length; i++) { otp += digits[Math.floor(Math.random() * digits.length)]; } return otp; } module.exports = { generateOTP };