+ 1

Why For Loop Is not Working | JS

Please check the below code : https://code.sololearn.com/WABTIlMfxqBU/?ref=app

5th Jul 2020, 10:02 AM
Himanshu Rai
Himanshu Rai - avatar
22 Réponses
+ 10
Glad you fixed it, and sorry about false accusations!
5th Jul 2020, 10:19 AM
Aymane Boukrouh
Aymane Boukrouh - avatar
+ 9
for (i = 3 ; i >= 0 ; i--) {document.write(i)} It will also work without logical operator try this.
5th Jul 2020, 10:11 AM
Ayush Kumar
Ayush Kumar - avatar
+ 8
That's weird then, try reloading the app.
5th Jul 2020, 10:15 AM
Aymane Boukrouh
Aymane Boukrouh - avatar
+ 7
I also don't see anything wrong with it, what were you expecting?
5th Jul 2020, 10:06 AM
Aymane Boukrouh
Aymane Boukrouh - avatar
+ 7
Himanshu Rai that's exactly what it's doing on my side, it shows: 3 2 1 0
5th Jul 2020, 10:10 AM
Aymane Boukrouh
Aymane Boukrouh - avatar
+ 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 !
5th Jul 2020, 10:13 AM
Ayush Kumar
Ayush Kumar - avatar
+ 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
5th Jul 2020, 10:14 AM
Ayush Kumar
Ayush Kumar - avatar
+ 4
🤔🤔 it seems alright according to your condition given in for loop
5th Jul 2020, 10:05 AM
Ayush Kumar
Ayush Kumar - avatar
+ 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😊
5th Jul 2020, 10:18 AM
Himanshu Rai
Himanshu Rai - avatar
+ 4
Aymane Boukrouh no need to sorry, moreover, there is mistake on my side, the code is alright.
5th Jul 2020, 10:23 AM
Himanshu Rai
Himanshu Rai - avatar
+ 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); }
7th Jul 2020, 10:02 AM
Haris
Haris - avatar
+ 3
This code is not showing any output on my side😬😬😬
5th Jul 2020, 10:12 AM
Himanshu Rai
Himanshu Rai - avatar
+ 3
for(i = 3 ; i >= 0 ; i--) {document.write(i)} it will also work without logical operator try this.
7th Jul 2020, 6:56 AM
hacker
hacker - avatar
+ 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.
5th Jul 2020, 10:08 AM
Himanshu Rai
Himanshu Rai - avatar
+ 2
But there is no output
5th Jul 2020, 10:10 AM
Himanshu Rai
Himanshu Rai - avatar
+ 2
I'm getting no output at output tab, not console
5th Jul 2020, 10:14 AM
Himanshu Rai
Himanshu Rai - avatar
+ 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); }
6th Jul 2020, 2:28 AM
Priyanshu Gupta(प्रियांशु गुप्ता)
Priyanshu Gupta(प्रियांशु गुप्ता) - avatar
+ 2
for(initialization; termination; incr/decr) {} Use this #followme
6th Jul 2020, 6:39 PM
Shakti Singh rathore
Shakti Singh rathore - avatar
+ 2
You can set for loop as :- for(i=3;i>=0;i--) document.write(i); And youre program will run
7th Jul 2020, 4:36 AM
Vivek Vadi
+ 1
I think the code of for loops is working ? Whats your problem
6th Jul 2020, 1:58 AM
Habbar Mohamed
Habbar Mohamed - avatar