Why doesnt this give an output? | Sololearn: Learn to code for FREE!
Neuer Kurs! Jeder Programmierer sollte generative KI lernen!
Kostenlose Lektion ausprobieren
0

Why doesnt this give an output?

I typed this but its not giving on output on the playground? Am i doing something wrong? for(i=4;i>1;i--) { document.write(i+"<br />"); }

6th Oct 2017, 8:19 PM
Jonathon Portlock
Jonathon Portlock - avatar
5 Antworten
+ 5
for(int i = 4; i > 1; i--) EDIT:- NOT FOR JS. Thanks @Naitomea for correction
6th Oct 2017, 8:48 PM
Meharban Singh
Meharban Singh - avatar
+ 3
oops, My bad @Naitomea, I will edit the answer.
6th Oct 2017, 9:34 PM
Meharban Singh
Meharban Singh - avatar
+ 1
Dod you write the code in HTML or JS section? I wonder because I just checked and it outputted 4 3 2 as intended, so the code itself is correct.
6th Oct 2017, 8:26 PM
Shadow
Shadow - avatar
+ 1
@Meharban JS doesn't have such data types as integer or float, instead you use the keyword var. But it is not necessary to use it in the first statement of the loop.
6th Oct 2017, 9:33 PM
Shadow
Shadow - avatar
0
JS section, it didnt give an error, so it might just be me :/
6th Oct 2017, 8:32 PM
Jonathon Portlock
Jonathon Portlock - avatar