+ 1

JavaScript Password generator

Can someone please explain how this code work for generating password. Method by method. Math.random().toString(10).slice(2) + Math.random().toString(10).slice(2) );

8th Jul 2020, 7:32 AM
Ibrahim Yusuf
Ibrahim Yusuf - avatar
2 ответов
+ 3
Math.random() generates a random number between 0 and 1. Then you convert it into string: 0.273785732179 //Something like this. Then with slice, slice the string from the 3rd pos to the end. Making it: 273785732179
8th Jul 2020, 8:06 AM
Arnesh
Arnesh - avatar
+ 3
Then you follow the same process and make another random number. Then, you combine them both. And get your password.
8th Jul 2020, 8:06 AM
Arnesh
Arnesh - avatar