Is there a way to get a breakline in Javascript? just like println
in Java without using < br>
after every statement. I tried document.writeln
because I am using it in HTML.However, it only gives a space not a breakline. Using < br>
is quite redundant as I need to write it every time and writeln
is not giving me what I want. I googled it a lot but couldn't find any helpful solution. The following is my code, if somebody can help, it would be appreciated.
var list = [1, 3, 5, 7];
for(var i=0; i<list.length; i++){
document.writeln(list[i]);
}
Put it in <pre>
tag or use css white-space
to fit your needs
<pre>
<script>
var list = [1, 3, 5, 7];
for(var i=0; i<list.length; i++){
document.writeln(list[i]);
}
</script>
</pre>