I created a simple calculator in javascript where I will input 2 numbers then select an operation and perform that operation but how come in this code the only thing that shows a correct answer is "+"
and "-"
here's the code
var fnum;
var secondNum;
var operation;
function msg(val) {
fnum = document.getElementById("fnumtext").value += val;
}
function showOperation(oper)
{
document.getElementById("fnumtext").value = "";
document.getElementById("operation").value = oper;
operation = oper;
}
function equal() {
secondNum = document.getElementById("fnumtext").value;
var num1 = parseInt(fnum)
var num2 = parseInt(secondNum);
if(document.getElementById("operation").value == "+"){
document.getElementById("fnumtext").value = parseInt(fnum) + parseInt(secondNum);
}else if(document.getElementById("operation").value == "-"){
document.getElementById("fnumtext").value = num1-num2;
}else if(document.getElementById("operation").value == "*"){
document.getElementById("fnumtext").value = num1 * num2;
}else if(document.getElementById("operation").value == "/"){
document.getElementById("fnumtext").value = (parseInt(fnum) / parseInt(secondNum));
}
}