I'm creating a code in which the user can calculate the area of a rectangle. After inputting the height and width when prompted, the site should then print the height, width, and area values within a table. The height and width code works and prints properly, but the area will not print. Where am I going wrong?
Here is the separate JavaScript code.
var height = prompt("Please enter the height");
var width = prompt("Please enter the width");
function calcArea(height, width) {
var area = height * width;
return area;
}
Here is the HTML code in which the JavaScript's outputs are coded.
<table>
<caption>Calculate the Area of a Rectangle</caption>
<tr><td class="makert">Height:</td>
<td class="makectr"> <script>document.write(height);</script></td></tr>
<tr><td class="makert">Width:</td>
<td class="makectr"> <script>document.write(width);</script></td></tr>
<tr><td class="makert">Area:</td>
<td class="makectr"> <script>document.write(area);</script></td></tr>
</table>