In the inputDigit function , the ternary operator (?) is used to check if the current value displayed on the calculator is zero. If so, calculator .displayValue is overwritten with whatever digit was clicked. Otherwise, if displayValue is a non-zero number, the digit is appended to it through string concatenation.
And the calculate function will take care of that logic for us. That function is defined down below. After our calculation, we need to clear the current buffer to make room for the new number and we set the currentOperation variable to its new value.
If any button detected the 'click' event (ie, if the user clicked on any button), then we need to activate a function called "calculate ". The calculate function is going to do all the magic. It will take the event object as its first argument and does the rest. OK now just code what we have said.