← Back to challenges

Sum Quadratic Roots

JavaScriptHardalgebramath

Instructions

Given a, b and c, find the roots of the equation ax^2 +bx +c = 0 and then add them together.

  • Round your answer to two decimal places.
  • If there is only one real root return 1.
  • If there are no real roots, return 0.

Examples

findRootsSum(2, 4, -6) ➞ -2.00

findRootsSum(3, 4, -3) ➞ -1.33

findRootsSum(4, 3, -8) ➞ -0.75

Notes

The Discriminant of a quadratic equation is b^2-4(a)(c).

javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.