+ 2
My code doesn't work
Hi guys,I'm here to ask you about my code: i'm making a password generator with a string of the users in javascript, but it doesn't work,and when i submit the page doesn't show me the password: maybe with the code you can have a better understanding: search in code playground,in section web, the code: Password generator javascript ask Make attention: some identifiers and the HTML are written in Italian,so use a translater
8 Answers
+ 1
Hi Michele
I think you have a scope issue.
All of your code is inside the Window.onload() function
This means that it is not available in the Global scope of the DOM at the time that you enter the password.
You need to pull the function funzione() out of the window on load so it is in the global scope.
+ 1
Thank for the reply,I've made what have you said,but the the code still not work.
Please recheck the code
+ 1
So letterale.lenght; was spelt wrong
should be
letterale.length;
0
Sorry,but the code does not work,and aftrer the modify, the page block and crash.What can i do?
0
Hi Michele
you seemed to have spelled length wrong in quite a bit of the code.
I'm not sure what your intention is, but I think you are looking to scamble
the letters and the numbers?
The algorithm is wrong in that when you generate the random indexes, they can be non unique, so you get duplicates...is this what you want?
If you describe to me what you are trying to do with the numbers and the letters I can try and re-write it for you.
0
the numbers are used for determine the position of the characters in the arrays
0
Hi Miichele
I have knocked this up using your original Algo, which as I said has problems with duplicates, but it produces out put as per what I think your code was doing. Hopefully you can use this to fix up the Algorithm so it does exactly what youa re after.
https://code.sololearn.com/WrUI20g9JguA/#js
The main issue with your code is that you are mixing up arrays and strings. So I had to convert everything to array then back to string.
If you raplace my randomfunc with something that produces unique indexes then I think you are good to go ;-)
0
thanks for the reply,thanks for the time,but i couldn't understand the code becouse i don't know so man methods,so it's time to study!
Thanks again