Manipulation / script.js
Swathi6's picture
Create script.js
d1cfa70 verified
raw
history blame
593 Bytes
// 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';
}
}