#!/usr/bin/env node; /****************************************************************************** * This program computes the roots of quadratic equations * of the form Ax^2 + Bx + C = 0 * * Copyright © 2020 Richard Lesh. All rights reserved. *****************************************************************************/ const A = 2.0; const B = 4.0; const C = 1.0; const main = async () => { let discriminant = B * B - 4. * A * C; discriminant = Math.sqrt(discriminant); let root1 = (-B + discriminant) / (2. * A); let root2 = (-B - discriminant) / (2. * A); console.log(["root #1: ", root1].join('')); console.log(["root #2: ", root2].join('')); } main().catch( e => { console.error(e) } );