display = ''; var press = function (key) { if (key === '=') display = eval(display); else display = display + key; print(display); } press(1); press("+"); press(2); press("="); press("+"); press(3); press("=");press(4);
Output