diff --git a/script.js b/script.js index 5f39b2e..a9d1349 100644 --- a/script.js +++ b/script.js @@ -20,6 +20,7 @@ Array.prototype.forEach.call(buttons, function (button) { if ( trimmedButtonValue != "=" && trimmedButtonValue != "C" && + trimmedButtonValue != "." && trimmedButtonValue != "x" && trimmedButtonValue != "\u00F7" && trimmedButtonValue != "\u221A" && @@ -41,7 +42,9 @@ Array.prototype.forEach.call(buttons, function (button) { equals(); } else if (trimmedButtonValue === "C") { clear(); - } else if (trimmedButtonValue === "x") { + }else if (trimmedButtonValue === "."){ + dot() + }else if (trimmedButtonValue === "x") { multiply(); } else if (trimmedButtonValue === "\u00F7") { divide(); @@ -134,6 +137,21 @@ function clear() { display.value = ""; } +function dot(){ + let num = display.value.split(""); + let flag = 0; + for(var i=0;i