How do I make all of the items inside document.get on new lines? I've tried br/ and \n. Neither of which work. They either cause the JavaScript to run incorrectly or don't create new lines. I know I can put each in its own paragraph element but for my purposes I have to have it all in one paragraph element.
<script type="text/javascript">
<!--
var firstString = prompt(" Enter the first number ", "");
var secondString = prompt(" Enter the second number ", "");
var num1 = parseFloat(firstString);
var num2 = parseFloat(secondString);
var addition = num1 + num2; // Addition of num1 and num2
var subtraction = num1 - num2; // Subtraction of num1 and num2
var multiplication = num1 * num2; // Multiplication of num1 and num2
var division = num1 / num2 // Division of num1 and num2
//These are the ones I'm trying to get to appear on separate lines
document.write (
"<p> First Value Entered: " + num1 + \n
"Second Value Entered: " + num2 + \n
"Sum: " + addition + \n
"Difference: " + subtraction + \n
"Product: " + multiplication + \n
"Quotient: " + division + "</p>"
);
// -->
</script>
document.write, it's part of an ancient JS API from before we had DOM manipulation functions and should never be used (and it's dangerous: it really doesn't do what you think it does). Create your stuff withdocument.createElement, set their content with.textContent=...(not.innerHTML, because that's just more DOM content, create it as such) and then add it to the DOM withdocument.body.appendChild(...)/element.appendChild(...)