The target of this project was create a One-time password generator when the user clicks on the "generate password" button, a combination of numbers will immediately appear along with a counter. When the time reaches zero the password will expire and it will be necessary to generate another code.
A one-time password (OTP) is a sequence of numbers and/or characters that is generated and sent to the user to be used in a single login attempt or transaction, for this reason the password is also called "one-time" password.
Math
library;Math.floor
function return the floor of any floating number to an integer value;Math.random()
is a function that returns any random number between 0 and 1.Learn more about the above functions in the documentation: Math.random(), Math.floor().
setTimeout()
andsetInterval()
I created a function so that, every 10 minutes the page is reloaded, forcing the user to need to generate a new code. Which reads as if the OTP code has expired.Learn more about the functions used and mentioned above in the MDN documentation: SetTimeout(), setInterval().