Spaces:
No application file
No application file
// Function to append the clicked button value to the display | |
function appendToDisplay(value) { | |
document.getElementById('display').value += value; | |
} | |
// Function to clear the display | |
function clearDisplay() { | |
document.getElementById('display').value = ''; | |
} | |
// Function to calculate the result of the expression in the display | |
function calculateResult() { | |
try { | |
let result = eval(document.getElementById('display').value); | |
document.getElementById('display').value = result; | |
} catch (error) { | |
document.getElementById('display').value = 'Error'; | |
} | |
} | |