This should be a quadratic equation root finder program using JavaScript. I wrote the code but there apparently is a mistake because when I click 'Calculate' the result is "x1: NaN; x2: NaN". Can somebody please show me the mistake?
function result() {
var a = document.getElementById('a');
var b = document.getElementById('b');
var c = document.getElementById('c');
var d = Math.sqrt(b*b-4*a*c);
var divide = (2 * a);
var x1 = (-b + d)/divide;
var x2 = (-b - d)/divide;
document.write("x1: " + x1 + "<br/>");
document.write("x2: " + x2 + "<br/>");
}