Smart All in One Calculator App

Smart All-in-One Calculator App

Addition Subtraction Multiplication Division

Result:

document.getElementById(‘calculateBtn’).addEventListener(‘click’, function() { const value1 = parseFloat(document.getElementById(‘inputValue’).value); const value2 = parseFloat(document.getElementById(‘secondValue’).value); const operation = document.getElementById(‘operationSelect’).value; let result = 0; switch(operation) { case ‘addition’: result = value1 + value2; break; case ‘subtraction’: result = value1 – value2; break; case ‘multiplication’: result = value1 * value2; break; case ‘division’: result = value1 / value2; break; default: result = ‘Invalid operation’; } document.getElementById(‘resultText’).innerText = ‘Result: ‘ + result; });

Leave a Reply

Your email address will not be published. Required fields are marked *