слабоумная мразь не хочет писать калькулятор, гнида! let operandOne=0, operandTwo=0, oneTwo=True, res, mem; let t1=document.querySelector("#t1"); let b1=document.querySelector("#b1"); let b2=document.querySelector("#b2"); let bRes=document.querySelector("#bRes"); let bPlu=document.querySelector("#bPlu"); b1.onclick=function(){ mem=False; if(oneTwo){ if(operandOne==0){ operandOne+=1; } else{ operandOne+="1"; } t1.value=operandOne; } else{ if(operandTwo==0){ operandTwo+=1; } else{ operandTwo+="1"; } t1.value=operandTwo; } } b2.onclick=function(){ mem=False; if(oneTwo){ if(operandOne==0){ operandOne+=2; } else{ operandOne+="2"; } t1.value=operandOne; } else{ if(operandTwo==0){ operandTwo+=2; } else{ operandTwo+="2"; } t1.value=operandTwo; } } bPlu.onclick=function(){ t1.value="+"; oneTwo=False; if(mem){ operandOne=res; } } bRes.onclick=function(){ res= +operandOne+ +operandTwo; t1.value=res; operandOne=0; operandTwo=0; mem=True; oneTwo=True; }

Теги других блогов: веб-разработка JavaScript калькулятор