There is a code that calculates the intersection point of the segments (copied it).

An error occurs that x1 - undefined .

 function d(х1, у1, х2, у2, х3, у3, х4, у4) { let x, y; x = ((x1 * y2 - x2 * y1) * (x4 - x3) - (x3 * y4 - x4 * y3) * (x2 - x1)) / ((y1 - y2) * (x4 - x3) - (y3 - y4) * (x2 - x1)); y = ((y3 - y4) * x - (x3 * y4 - x4 * y3)) / (x4 - x3); return x, y; } console.log(d(0, 0, 120, 90, 0, 60, 120, 60)); 

Closed due to the fact that off-topic participants andreymal , Air , 0xdb , freim , LFC 10 Mar at 9:33 .

It seems that this question does not correspond to the subject of the site. Those who voted to close it indicated the following reason:

  • "The question is caused by a problem that is no longer reproduced or typed . Although similar questions may be relevant on this site, solving this question is unlikely to help future visitors. You can usually avoid similar questions by writing and researching a minimum program to reproduce the problem before publishing the question. " - andreymal, Air, 0xdb, freim, LFC
If the question can be reformulated according to the rules set out in the certificate , edit it .

    2 answers 2

    Do you mix Russian and English characters on purpose?

     function d(x1, y1, x2, y2, x3, y3, x4, y4) { let x, y; x = ((x1 * y2 - x2 * y1) * (x4 - x3) - (x3 * y4 - x4 * y3) * (x2 - x1)) / ((y1 - y2) * (x4 - x3) - (y3 - y4) * (x2 - x1)); y = ((y3 - y4) * x - (x3 * y4 - x4 * y3)) / (x4 - x3); return x, y; } console.log(d(0, 0, 120, 90, 0, 60, 120, 60)); 

    • even confused a little bit at once - Vitaly Shebanits

    Your mistake is due to the fact that I mixed up the Cyrillic alphabet and the Latin alphabet ... mixed arguments and variables are different ..

     function d(x1, y1) { let x, y; x = x1 * y1 y = x1 + y1 return x, y; } console.log(d(120, 60));