First, I use this as the base for the calculator.
let h = -2
let a = 3
let k = 10
let step1 = h * h
let step2 = h + h
let step3 = a * step2
let step4 = a * step1
let step5 = step4 + k
console.log(a + "x² + " + step3 + "x + " + step5)
It works, after trying with different a, h, and k values, but when I make it to accept user input using HTML and this code...
document.getElementById("submit").onclick = function(){
let a = document.getElementById("aQuad").value;
let h = document.getElementById("hQuad").value;
let k = document.getElementById("kQuad").value;
let step1 = h * h
let step2 = h + h
let step3 = a * step2
let step4 = a * step1
let step5 = step4 + k
console.log(a + "x² + " + step3 + "x + " + step5)}
It breaks. Instead of answers like 3x² - 12x + 22 I get 3x² + NANx + 1210. I checked my HTML code too and I believe it is not the issue.