JSFiddle - React, Tailwind, and code Playground

by 林 羿緯

JavaScript

function solve (a1,b1,c1,a2,b2,c2) {
	var x, y;
  x = (b2*c1-b1*c2)/(a2*b1-a1*b2);
  y = -(a2*c1-a1*c2)/(a2*b1-a1*b2);
    return [x,y];
}


var roots = solve (1,2,-3,1,2,-3);
//console.log (roots);
if (roots.length === 0)
    console.log ('no real roots');
else 
    console.log ('x: ' + roots[0] + '; ' + 
                 'y: ' + roots[1]);