Published
- 1 min read
generate otp using javascript
The solution for this is noted below
generate otp using javascript
Solution
function generateOTP() {
// Declare a digits variable
// which stores all digits
var digits = '0123456789'
let OTP = ''
for (let i = 0; i < 4; i++) {
OTP += digits[Math.floor(Math.random() * 10)]
}
return OTP
}
Try other methods by searching on the site. That is if this doesn’t work