What is wrong with my code?
Here is the html code: <!DOCTYPE html> <html> <head> </head> <body> <h1 id="result" align="center">0</h1> <button onclick="operation('+')">+</button> <button onclick="number(1)">1</button> <button onclick="number(2)">2</button> <button onclick="number(3)">3</button> <br> <button onclick="operation('-')">-</button> <button onclick="number(4)">4</button> <button onclick="number(5)">5</button> <button onclick="number(6)">6</button> <br> <button onclick="operation('*')">*</button> <button onclick="number(7)">7</button> <button onclick="number(8)">8</button> <button onclick="number(9)">9</button> <br> <button onclick="operation('/')">/</button> <button onclick="point()">.</button> <button onclick="number(0)">0</button> <button onclick="equals()">=</button> </body> </html> And here is the Javacript code: var eq=0; var x; var y; var a=0; var b=0; var c=0; var first=0; var second=0; var oper; var res; function number(x) { if(b===0) { if (a===0) { first=x; a++; eq=first; } else { first+=String(x); eq+=String(first); } } else { if (c===0) { second=x; c++; } else { second+=String(x); } eq+=second; } } function operation(y) { oper=String(y); eq+=String(y); b++; } function equals() { switch(oper) { case '+': res=Number(first)+Number(second); break; case '-': res=Number(first)-Number(second); break; case '*': res=Number(first)*Number(second); break; case '/': res=Number(first)/Number(second); break; } eq+= "=" + res; } setInterval(update, 1); function update() { document.getElementById("result").innerHTML = eq; }