Quadratic equation solver in JavaScript The task is to implement a solveEquation function, which solves the Quadratic equation. Each equality has exact 2 integer solutions. Return those numbers as an ordered array.

Example:

const solutions = solveEquation('2 * x^2 - 10 * x + 12');
console.log(solutions); // [2, 3]


Solution:

function solveEquation(equation) {
    // Your solution here
    let a, b, c;
    // Using ES6 destructuring
    [a, b, c] = getValues(equation);
    return getXList(a, b, c);
}

// Determine a,b,c and return in an array
function getValues(equation) {
    // ax^2 + bx + c
    let a = equation.split(' * x^2')[0];
    let aSign = equation.split(a + ' * x^2')[0];
    // Assigns +- a
    a = parseInt(aSign + a);
    let bSign = equation.split(a + ' * x^2 ')[1].charAt(0);
    let b = equation.split(' * x^2 ' + bSign + ' ')[1].split(' * x ')[0];
    // Assigns +- b
    b = parseInt(bSign + b);
    // Assigns +- b
    let cSign = equation.split(' * x ')[1].charAt(0);
    let c = equation.split(' * x ' + cSign + ' ')[1];
    // Assigns +- c
    c = parseInt(cSign + c);
    return [a, b, c];
}
// Returns ordered Array
function getXList(a, b, c) {
    let list = [];
    list.push(getX('+', a, b, c));
    list.push(getX('-', a, b, c));
    list.sort((a, b) =&gt; a - b);
    return list;
}
// Returns X
function getX(sign, a, b, c) {
    // represent x = (- b +- √b^2-4ac)/2a as x = (b1 +- c1)/a1 
    let x, b1, a1, c1;
    b1 = parseInt(- + b);
    a1 = 2 * a;
    c1 = Math.sqrt((b * b) - 4 * a * c);
    return x = Math.round((sign === '+') ? ((b1 + c1) / a1) : ((b1 - c1) / a1));
}

console.log(solveEquation('2 * x^2 - 10 * x + 12'));// [2, 3]
console.log(solveEquation('-20 * x^2 - 108797540 * x - 130011773690520'));// [-3667291, -1772586]
console.log(solveEquation('294 * x^2 - 141195558 * x - 1600964090384736'));// [-2105744, 2586001]
console.log(solveEquation('-267 * x^2 + 296412186 * x + 4722715166392080'));// [-3687112, 4797270]
console.log(solveEquation('-381 * x^2 + 2871374115 * x - 5385906614046864'));// [3516911, 4019504]
console.log(solveEquation('-154 * x^2 + 645219652 * x - 602658645850800'));// [1405588, 2784150]


The main reason I post this program is to get critical feedback and perhaps improve my coding style.
Buggy as.
Unusable I made a single change and then could not get it to work (turned out I added an extra space)
Bugs
Any spaces in the wrong spot, and deviations from the simplified equation, any fractions and more will cause the code to throw a variety of errors.
Expectation
When you create a function people that use it have idiomatic expectations. You must attempt to conform at least to common variations on these expectations, and or ensure that your code does not throw errors if the input is not as expected.
One would expect a equation solver to be robust and handle all the standard input variations, like be

invariant to white spaces,
invariant to equation layout (1 * x ^ 2 + 1 * x ^ 2) === ( 2 * x ^ 2)
invariant to form of power (x * x) === (x ^ 2)
invariant to implied constants (x + 0) === (x), (1*x) === (x) and (2*x^2+0*x) === (2*x^2)
invariant to equation form (x + 1) ^ 2 === ((x + 1) * (x + 1)) === (x ^ 2 + 2 * x + 1)
I invariant to implied multiplier (2x === 2 * x) Note the number (or variable) if before x and has no operator, the multiplication * is always implied.

Other problems.
Not all quadratics have solutions.

A quadratic can have zero solutions as it is above of below the x axis. Eg x ^ 2 + 1
A quadratic can have one solution if it just touches the x axis eg x ^ 2
A quadratic can have two solution eg x ^ 2 - 1 * x

Quadratics can also include fractions  1/2 or 0.5. You should also be able to add the equations strings together, two or more 2nd order polynomials added together (joined with a &quot;+&quot; or &quot;-&quot;) should equate into a valid quadratic.
Naming
The function naming is rather bad. To name a few examples

getValues maybe parseEquation
getXList mabe solveQuadratic
list maybe coefficients

Constants
You should use const for constants. Some examples...
const [a, b, c] = getValues(equation);

const list = [];

const cSign = equation.split(' * x ')[1].charAt(0);

And most likely more problems but as the code is so hard to use I have not looked any deeper into your algorithm.
Conclusion.
I would say &quot;Try again.&quot; as it is not at all what I would expect from a function that solves quadratics.