The if loop only works if there is an alert in it .. just by removing the alert ("LoL") it stops working, is it a bug or a bug? the function overwrites the operation sign on the calculator
function changeAction(value) { var input = document.getElementById("t"); if (input.value.length == 2) { alert("LoL"); if (input.value =='++' || input.value == '-+' || input.value =='/+' || input.value =='*+') { input.value = '+'; } if (input.value =='--' || input.value == '/-' || input.value =='*-' || input.value =='+-') { input.value = '-'; } if (input.value =='-*' || input.value == '/*' || input.value =='**' || input.value =='+*') { input.value = '*'; } if (input.value =='//' || input.value == '*/' || input.value =='*-/' || input.value =='+/') { input.value = '/'; } } }
ifit's not a loop, where does the assumption that it stops working? how exactly does not work? How is changeAction called? - Grundyifcan be replaced by something like this:if (input.value) input.value = input.value.charAr(input.value.length - 1);- Yaantinput.value[index]- Grundy for a long timeinput.value =='*-/'- here the length is not 2. - Qwertiy ♦