I was trying to find the total sum of the price a user would input in the pop-up window and display the total. Would i have to add another line under the output? I am trying to add the total along the outMsg but not successful. Thanks
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Array 02</title>
</head>
<form action="">
<p>BOOK SALE</p>
<p id="Books"</p>
<input type="button" value="Start" onClick="Books()";>
</form>
<body>
<script>
function Books()
{
//define variables
var arraySize = 2;
var bookName = new Array(arraySize);
var bookPrice = new Array(arraySize);
var total = 0;
var outMsg = "";
for(var i = 0; i < arraySize; i++)
{
bookName[i] = prompt('Enter Book Name: ', "");
bookPrice[i] = prompt('Enter the Price: ',0);
}
for(var i = 0; i < arraySize; i++)
{
outMsg = outMsg + bookName[i] + " " + bookPrice[i] + "</br>" + total; // put backslash n (\n) to show on window
//alert(outMsg)
document.getElementById("Books").innerHTML = outMsg;
}
}
</script>
</body>
<html>
<p id="Books"</p>is this a typo or your problem? You do not exit the opening<p>tag.<).