html – Calculadora Bhaskara Javascript

let valorA = parseFloat (document.getElementById (###). value);
var numA = valorA;

let valorB = parseFloat (document.getElementById ("# b"). value);
var numB = valorB;

let valorC = parseFloat (document.getElementById (###). value);
var numC = valueC;

function calc () {
var delta = ((Math.pow (numB, 2)) - ((4 * numA) * numC));
var raiz = Math.sqrt (delta);
var base = 2 * numA;
// validar a, b, c
if (delta <0)
{
alert ("Nao tem resposta")
}
if not (delta === 0)
{
var deltaX = (numB * (- 1)) / base;
document.getElementById (x1). innerHTML = deltaX;
}
other
{
var x1 = (- numB + raiz) / base;
var x2 = (- numB-raiz) / base;
document.getElementById (& # 39; delta & # 39;). innerHTML = delta;
document.getElementById (x1). innerHTML = x1;
document.getElementById (x2). innerHTML = x2;
}
}

let button = document.querySelector (# buttonC & # 39;);
button.addEventListener ('click', calc);

    

Bhaskara calculadora