Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

114
Views
How to implement javascript into an html page

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.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

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>
I hope this was helpful.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!