quadratic-solve
v2.0.0
Published
Solve quadratic equations
Downloads
6
Maintainers
Readme
⚙️ Installation
npm i quadratic-solve
CDN Links:
- https://cdn.jsdelivr.net/npm/[email protected]/quadratic-solve.js
- https://www.unpkg.com/[email protected]/quadratic-solve.js
📖 Usage
● Import
// ES6
import quadraticSolve from "quadratic-solve";
// commonjs
const quadraticSolve = require("quadratic-solve");
● Solve
const solved = quadraticSolve(1, -4, 4); // arguments - (a, b, c)
console.log(solved); // output - [2, 2]
It will return undefined
if there is no solution.
● Verify
const solved = quadraticSolve(1, -4, 4); // arguments - (a, b, c)
const verified = quadraticSolve(1, -4, 4, [2, 2]); // arguments - (a, b, c, [root1, root2])
const incorrect = quadraticSolve(1, -4, 4, [2, 3]);
console.log(verified); // output - True
console.log(incorrect); // output - False