I’ve been stuck for a week trying to really grasp how to use loops, I’m currently trying to do a random password generator project on Scrimba and I can’t complete it.
The project gives me an array with 91 characters, numbers and symbols and wants me to create a password on a button click. it also wants the password to be 15 characters long
the ridiculous thing is that I could probably complete this project without using a loop by creating random variables like this —
let randomCharacter = Math.floor(Math.random() * array.length)
let randomCharacterTwo = Math.floor(Math.random() * array.length)
let randomCharacterThree = Math.floor(Math.random() * array.length)
and I’d basically create another variable that is just adding these up 15 times to create a 15 character random password. I’ve tried this and it worked.
I know this is not the correct way to do this project and I know it’s calling for me to use loops but I just simply can’t grasp them.
I get how to create loops and I get the syntax of them, but I don’t understand how to actually use them. I’ve spent so much time stuck on this and I’m really getting discouraged.
does anyone have a source that actually really helped them with loops?