diff --git a/index.html b/index.html index dba9f04..3f3d97e 100644 --- a/index.html +++ b/index.html @@ -173,6 +173,8 @@

Calculator

+ diff --git a/script.js b/script.js index 03eb4ce..71d6bdc 100644 --- a/script.js +++ b/script.js @@ -245,6 +245,17 @@ Array.prototype.forEach.call(buttons, function (button) { } }); }); +document.getElementById('logBtn').addEventListener('click', log); +function log() { + const num = parseFloat(display.value); + if (isNaN(num) || num <= 0) { + openToast('error', 'Error', 'Enter a positive number to calculate log'); + return; + } + display.value = Math.log10(num); + resultDisplayed = true; + manageLocalStorage(display.value); +} // Prevents multiple decimal points from being typed through keyboard function isNumber(num) {