Why the correct result not displayed? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Why the correct result not displayed?

for (i = 1, text="Hi!",; i <= 5; i++) { document.write(i + text + "<br />"); } I want to show it like this:- 1Hi! 2Hi! 3Hi! 4Hi! 5Hi!

4th Jun 2021, 4:37 AM
Harsh
Harsh - avatar
9 Answers
+ 4
What is your programing language
5th Jun 2021, 1:36 PM
Tharul Nejana
Tharul Nejana - avatar
+ 1
for ( /* initialization */; /* condition */; /* end of each iteration */ ) { // body (iterations) }
4th Jun 2021, 4:53 AM
visph
visph - avatar
0
Oh yeah ! Thanx One more var i = "Hi!"; for (; i = "Hi!";) { console.log(i); } I want to display Hi! 5 times but, it says, "Seems like your code will run forever". How to code properly.
4th Jun 2021, 4:51 AM
Harsh
Harsh - avatar
0
To SSSSSS, Can you explain how i is working ?
4th Jun 2021, 4:57 AM
Harsh
Harsh - avatar
0
Thanx and final question how you mentioned me in this answer ?😋😋😋
4th Jun 2021, 5:01 AM
Harsh
Harsh - avatar
0
initialization part is executed once at loop start condition is checked at each iteration start to determine if the loop continue or else exit end of each iteration is usually where you increment a counter
4th Jun 2021, 5:03 AM
visph
visph - avatar
0
Harsh Kishore to mention.. Just type `@` ,after that list of recent users will apear ,you can mention any just clicking on name. Hope u got it
4th Jun 2021, 5:38 AM
saurabh
saurabh - avatar
- 1
Use a while loop insted, set variable i before the loop, then use while i is less or equal to five and then pit echos inside A Let i = 0 Let text = hi While(i ‹= 5){ ducument. write(i + text + "‹br›") }
5th Jun 2021, 3:21 PM
HMD
HMD - avatar
- 3
To visph, What the heck is this answer ????????
4th Jun 2021, 4:58 AM
Harsh
Harsh - avatar