+ 2

java print out

hey guys, I was just paying with some codes and I realized if I don't use the "+" sign after I in princesses in the "document.write" it will show me an error!! what is the purpose of that plus sign? the code is: var i = 0; for (; i <= 10; ) { document.write(i+ "<br />"); i++; }

12th Feb 2018, 2:28 PM
kanaan
kanaan - avatar
2 Answers
+ 6
As i is a number and <br /> is a html tag, + sign is needed to *join* them together. Even if the former would be a string, then also we had used + as both are two unique elements!
12th Feb 2018, 3:06 PM
777
777 - avatar
+ 3
thank you blue for your awesome explanation 😊
12th Feb 2018, 3:43 PM
kanaan
kanaan - avatar