js-exercises/prototyping/raiz.js

25 lines
527 B
JavaScript
Raw Permalink Normal View History

2024-01-14 11:19:42 +01:00
document.write("What<br>");
var a = parseInt(prompt("Introduzca la A:"));
var b = parseInt(prompt("Introduzca la B:"));
var c = parseInt(prompt("Introduzca la C:"));
var d = Math.pow(b, 2) - 4 * a * c;
if (d >= 0) {
//TODO: Remember math class
var x1 = -b + Math.sqrt(d) / 2 * a;
var x2 = -b - Math.sqrt(d) / 2 * a;
document.write(`x1 = ${x1.toFixed(2)}<br>`);
document.write(`x2 = ${x2.toFixed(2)}`);
} else {
document.write(`Raíz imaginaria?`);
}
//2 25 2
document.write(`<br>d = ${d}`);
//alert(`a\na`);