I have a problem! I make a calculator on js. I have a variable d, by default it is equal to 2. When a user clicks on a sign, for example, on "+", the value of the variable changes to 3. And so, in fact, the program should determine which sign the user put (I know this is silly, but I could not think of anything better, since I am a beginner) and calculate. In the end, I made a function rez, which is triggered when I click on the "equal" button. But for some reason, the "if" works strangely, and the calculator is constantly folding, regardless of what sign I put! What is the reason???
function rez(){ var num1, num2, znak, result, stroka; if (d=3){ num1 = +document.getElementById("out").textContent; num2 = +document.getElementById("out2").textContent; znak = document.getElementById("out1").textContent; result = num1 + num2; stroka = document.getElementById("out3"); stroka.innerHTML = result; } else if(d=4){ num1 = +document.getElementById("out").textContent; num2 = +document.getElementById("out2").textContent; znak = document.getElementById("out1").textContent; result = num1 - num2; stroka = document.getElementById("out3"); stroka.innerHTML = result; } }