JSFiddle - React, Tailwind, and code Playground

by Malik Naik

HTML

<div>
	<input type="text" id="x" placeholder="x">
	<input type="text" id="y" placeholder="y">
	<input type="button" value="Find distance from origin" onclick="calculate();">
</div>

JavaScript

function calculate(){
    var x = document.getElementById("x").value;
    var y = document.getElementById("y").value;
    alert("Distance from origin to x and y is : " + Math.round(Math.sqrt(Math.pow(x,2)+Math.pow(y,2))));
}