+ 1
Why For Loop Is not Working | JS
Please check the below code : https://code.sololearn.com/WABTIlMfxqBU/?ref=app
22 Answers
+ 10
Glad you fixed it, and sorry about false accusations!
+ 9
for (i = 3 ; i >= 0 ; i--)
{document.write(i)}
It will also work without logical operator try this.
+ 8
That's weird then, try reloading the app.
+ 7
I also don't see anything wrong with it, what were you expecting?
+ 7
Himanshu Rai that's exactly what it's doing on my side, it shows: 3 2 1 0
+ 6
Hay Aymane Boukrouh I think he is asking that without logical operator his code is showing unexpected results.
but he is bit confused I think !
+ 6
Hay Himanshu Rai if it's not showing any output this might be you connection problem try it later.
some time its happened with me also
+ 4
🤔🤔 it seems alright according to your condition given in for loop
+ 4
Got it after restarting the app. But before, all app functions are working very fine except my code.
I think there may be error in app.
All thanks to you guys😊
+ 4
Aymane Boukrouh no need to sorry, moreover, there is mistake on my side, the code is alright.
+ 4
No need to write it like you have.
i=3 and it decreases, it'll never be 5 hence no need for the logical operator
for (i = 3; i >= 0; i--){
document.write(i);
}
+ 3
This code is not showing any output on my side😬😬😬
+ 3
for(i = 3 ; i >= 0 ; i--)
{document.write(i)}
it will also work without logical operator try this.
+ 2
Aymane Boukrouh I want the program to print the number from 3 to 0 using decrement operator.
If I don't put logical operator, it will go to print negative integers.
+ 2
But there is no output
+ 2
I'm getting no output at output tab, not console
+ 2
Hey Himanshu Rai , you have uselessly put i<=5 , it is still working w/o it
You have earlier mentioned that i=3 , so it will be always greater than 5 you should only write
for(let i = 3;i>=0;i--){
document.write(i);//well you should use console.log(i);
}
+ 2
for(initialization; termination; incr/decr)
{}
Use this
#followme
+ 2
You can set for loop as :-
for(i=3;i>=0;i--)
document.write(i);
And youre program will run
+ 1
I think the code of for loops is working ? Whats your problem