Well written for-loop doesn't work in browser console

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP

Well written for-loop doesn't work in browser console



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 (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.


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.



Click here





It will help if you edit the question and include the code in question.
– Mark Meyer
13 hours ago





I've uploaded like to screenshots in my Google drive. Thanks
–  Edmund
13 hours ago





You should copy and past the code into the question. Indent four spaces before each line and it will even format it nicely.
– Mark Meyer
12 hours ago





Please don't share images of code or external links to Google Drive, etc. because those links can disappear over time. Instead, add the code directly into the post and use the formatting tools to display them as text. See How to create a Minimal, Complete, and Verifiable example.
– Gino Mempin
12 hours ago






One of your for-loop looks like for(var z = 0; z >= 5; z++)  Why you're expecting iterarion with that condition and that initialization?
– Ele
12 hours ago



for(var z = 0; z >= 5; z++) 




1 Answer
1



Entry condition is not satisfied in your loop due to >= check



Your code:
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);



Hope this helps.






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Comments

Popular posts from this blog

Executable numpy error

PySpark count values by condition

Mass disable jenkins jobs