It is necessary to make so that in the calculator the first operand is remembered and rewritten by the second. To remember, I kind of did it, but I don’t quite understand how to do it to put them together.
<input type="button" value="7" onclick="calculator.answer.value += input.value;rememberFirstOperand();" /> function rememberFirstOperand() { var rep1 = /[/|*|+|-]/;//проверка на наличие операнда в строке input var rep2 = /[0-9](?=[*|/|+|-])/;//проверка что знак в конце первого операнда var tempValue = 0; if (rep1.test(calculator.answer.value) && rep2.test(calculator.answer.value)) { tempValue=calculator.answer.value; calculator.answer.value='';//очищаю для ввода второго элемента } }