Reputation: 49
Hey guys I want to ask if there is any way to write multiple lines in one JS alert box using for loop?
I WANT TO HAVE OUTPUT LIKE THIS WITH ONE STRING VARIABLE AND ANY LOOP, HOW CAN I HAVE OUTPUT LIKE THIS WITH ABOVE MENTIONED REQUIREMENTS?
Upvotes: 0
Views: 770
Reputation: 418
Use \n
alert("String 1\nString 2");
var p = '';
for (var i = 1; i < 5; i++) {
p+= "string " + i + '\n'
}
alert(p)
Upvotes: 2