+ 16

what is output

for (x=5; x>=9;x--); x--; alert(x);

12th Jun 2018, 1:58 PM
Shubham goyal
Shubham goyal - avatar
49 Réponses
+ 13
maybe 4. because loop starts from 5 but it won't run because condition is false. then it will go for x--, it will make x 4. alert(x); will popup 4 as a answer.
12th Jun 2018, 2:05 PM
Raj Chhatrala
Raj Chhatrala - avatar
+ 11
4
12th Jun 2018, 5:46 PM
Shubham goyal
Shubham goyal - avatar
+ 9
yes, it's right. the for loop just creates x.
13th Jun 2018, 3:42 PM
Minn queen
Minn queen - avatar
+ 8
sorry guess
13th Jun 2018, 12:04 PM
Minn queen
Minn queen - avatar
+ 8
4
13th Jun 2018, 5:48 PM
Vegito
Vegito - avatar
+ 7
4
12th Jun 2018, 6:15 PM
Vegito
Vegito - avatar
+ 7
14
13th Jun 2018, 11:39 AM
Minn queen
Minn queen - avatar
+ 7
i know it. but anyone was giving answer 4. and i gave 14 it's just for fun. ok boos
13th Jun 2018, 11:56 AM
Minn queen
Minn queen - avatar
+ 7
4
17th Jun 2018, 9:38 AM
💞ⓢⓦⓐⓣⓘ💞
💞ⓢⓦⓐⓣⓘ💞 - avatar
+ 5
Most likely 4. @) Good luck!
12th Jun 2018, 2:23 PM
Alexander Sokolov
Alexander Sokolov - avatar
+ 5
4
12th Jun 2018, 3:57 PM
Mattéo
+ 5
X is 5, and the loop doesnt run, so shouldn't it still be 5?
12th Jun 2018, 7:58 PM
Archie
Archie - avatar
+ 5
Output will be 4
13th Jun 2018, 5:48 AM
P∆WAN M∆URY∆
P∆WAN M∆URY∆ - avatar
+ 5
ADIL GAAFER FATHELRAHMAN no you're wrong because the for loop just creates x and assign 5 to it. after, x is decremented (-1) and its value is printed to screen. so x = 4.
13th Jun 2018, 3:18 PM
Mattéo
+ 5
what would the output be for: for(x=5;x=5;x--); alert(x);
15th Jun 2018, 8:42 AM
niteOwLTwO
niteOwLTwO - avatar
+ 4
4
12th Jun 2018, 4:57 PM
Samuel Carrera
+ 4
oh
12th Jun 2018, 8:04 PM
Archie
Archie - avatar
+ 4
I think 4.
13th Jun 2018, 4:49 AM
keev23i
keev23i - avatar
+ 4
yes, it's right. the for loop just creates x.
13th Jun 2018, 3:23 PM
Mattéo
+ 3
Åtomıc no because x is decremented after the for loop which doesn't run
12th Jun 2018, 8:04 PM
Mattéo