The perimeter for my code always comes back like 2020 4040 and so on and I cannot seem to figure out why when the variables are both numbers. I know it is a pretty simple fix but I cannot figure it out. I tried parseInt but that did not work either. Can anyone help explain to me what I need to add or change to get my perimeter to come up say 40 using say 10 and 10 for the width and height.
<head>
<meta charset="utf-8" />
</head>
<body>
<p>Click the button to calculate the area and perimeter of a rectangle.</p>
<button onclick="myFunction()">Try it out!</button>
<script>
function myFunction() {
var width = prompt("Please enter a width", " ");
var height = prompt("Please enter a height", " ");
var area = width * height;
var perimeter = (width + height) * 2;
if (width != null && height != null) {
alert("The area is " + area + " and the perimeter is " + perimeter + ".");
}
}
</script>
</body>
</html>