Using Document.Write
isn't usually a good thing to use as its probably not doing what you think its doing, but anyway.
In your code, assuming a
, b
and e
are string variables you need to put your line break inside the brackets.
document.write(a+"\n");
document.write(b+"<br/>");
Update
There is nothing wrong with document.write
but if you don't understand what it does it can be confusing.
Whatever string you pass to the function is appended to the end of the document.
Example:
<html>
<body>
<h1>
<script> document.write("My Header!"); </script>
</h1>
</body>
</html>
You might think that this would write the text "My Header!" inside the h1 tag, but the result will actually be something like this
<html>
<body>
<h1>
<script> document.write("My Header!"); </script>
</h1>
</body>
</html>
My Header!
Document.write is great if you have an <iframe>
or similar and you want to generate the whole document from scratch. Using it to change the current page doesn't work (very well). For changing the current page, you want to look into DOM Manipulation.
');` or `document.write('
' + b);` – Mamun Mar 16 '20 at 23:52
' + b)`, assuming *a* and *b* have been declared or created already. – RobG Mar 16 '20 at 23:52