JSFiddle - React, Tailwind, and code Playground

HTML

<p>Click the button to calculate the area and perimeter of a rectangle.</p>

    <button onclick="myFunction()">Click me</button>

JavaScript

function myFunction() {
            var width = prompt("Please enter a width", " ")*1;
            var height = prompt("Please enter a height", " ")*1;
            var area = width * height;
            var perimeter = Number(width + height)
            
            

            if (width != null && height != null) {
                alert("The area is " + area + " and the perimeter is " + perimeter + ".");
            }
        }