So i was trying to make a password generator, and I want to get random letters and numbers from different arrays and assign to a variable which will now serve as the generated password, and now to increase the length of the characters in password i make to for loop add two random uppercase and lowercase letters and a number every time for 15 times and I'm pretty sure i wrote it well but when i tested in chrome's console it returned undefined immediately without the loop even running. Then i tried even the most basic loop in the console and the same thing happened, sometimes my browser just freezes like it's an infinite loop but it's not.
所以我试图创建一个密码生成器,我想从不同的数组中获取随机字母和数字并分配给一个变量,该变量现在将作为生成的密码,现在增加密码中的字符长度。 for循环每次添加两个随机的大写和小写字母和一个数字15次,我很确定我写的很好,但是当我在chrome的控制台中测试时,它立即返回undefined而没有循环甚至运行。然后我甚至尝试了控制台中最基本的循环,同样的事情发生了,有时我的浏览器只是冻结,就像它是一个无限循环,但事实并非如此。
Here is a copy of a basic loop
for (var z=0; z>=5 ; z++) {console.log(z);}
The code above is the loop i use that my browser malfunctions, but i noticed one thing which is that the loop works when i increment the variable by 3 times its value i.e x*=3.
上面的代码是我使用的循环我的浏览器出现故障,但我注意到一件事是当我将变量增加3倍的值,即x * = 3时循环工作。
for (var x=3; x<10000 ; x*=3) {console.log(x);}
I really need your opinion on this I've tried the first in multiple browsers on my pc and I still get the same results. I don't know if the problem is from my browser.
我真的需要你的意见我已经尝试在我的电脑上的多个浏览器中的第一个,我仍然得到相同的结果。我不知道问题是否来自我的浏览器。
here is my google drive link for the images
1 个解决方案
#1
0
Entry condition is not satisfied in your loop due to >= check
由于> =检查,循环中的条目不满足
Your code: for (var z=0; z>=5 ; z++) {console.log(z);}
您的代码:for(var z = 0; z> = 5; z ++){console.log(z);}
It should be (assuming you want to iterate 5 times): for (var z=0; z<5 ; z++) {console.log(z);}
它应该是(假设您要迭代5次):for(var z = 0; z <5; z ++){console.log(z);}
Hope this helps.
希望这可以帮助。
#1
0
Entry condition is not satisfied in your loop due to >= check
由于> =检查,循环中的条目不满足
Your code: for (var z=0; z>=5 ; z++) {console.log(z);}
您的代码:for(var z = 0; z> = 5; z ++){console.log(z);}
It should be (assuming you want to iterate 5 times): for (var z=0; z<5 ; z++) {console.log(z);}
它应该是(假设您要迭代5次):for(var z = 0; z <5; z ++){console.log(z);}
Hope this helps.
希望这可以帮助。