I would like to implement this script into a html page :
function rcirc(x, y, m, b) {
let m2 = -1 / m;
let b2 = y - (m * x);
let y2 = (b2 - b) / (m - m2);
let x2 = (y2 - b) / m;
return [x2, y2];
}
var x = window.prompt("enter the x value: ");
var y = window.prompt("enter the y value: ");
var m = window.prompt("enter the m value: ");
var b = window.prompt("enter the b value: ");
let point = rcirc(x, y, m, b);
alert(point);
I tried adding <script></script> around the code but it does not work.
Hi Hoadi here is a working example of your code implemented into an html "website". The html renders after you clicked away the final alert.
<hml>
<body>
<h1>some stuff...</h1>
</body>
<script>
function rcirc(x, y, m, b) {
let m2 = -1/m;
let b2 = y - (m * x);
let y2 = (b2 - b) / (m - m2);
let x2 = (y2 - b) / m;
return [x2, y2];
}
var x = window.prompt("enter the x value: ");
var y = window.prompt("enter the y value: ");
var m = window.prompt("enter the m value: ");
var b = window.prompt("enter the b value: ");
let point = rcirc(x, y, m, b);
alert(point);
</script>
</hml>