General discussion
-
Topic
-
JavaScript Calculator Program Error
Hello this is Gulshan Negi
Well, I am writing a program for making calculator using JavaScript but it shows some error at the time of its execution.
I am getting error in this phase and here is my source code:const calculator = {
displayValue: ‘0’,
firstOperand: null,
waitingForSecondOperand: false,
operator: null,
}function inputDigit(digit) {
const { displayValue, waitingForSecondOperand } = calculator;if (waitingForSecondOperand === true) {
calculator.displayValue = digit;
calculator.waitingForSecondOperand = false;
} else {
calculator.displayValue = displayValue === ‘0’ ? digit : displayValue + digit;
}
}function inputDecimal(dot) {
if (calculator.waitingForSecondOperand === true) {
calculator.displayValue = “0.”
calculator.waitingForSecondOperand = false;
return
}I also checked and took a reference from a site but I dont know what thing I am missing.
Can anyone give their suggestions on this ?
ThanksNote: URL of site referenced removed by moderator.