From 38a02d23e7ebfbde85ffb02255be5aaeabd5ee1c Mon Sep 17 00:00:00 2001 From: Bashar V I Date: Fri, 7 Oct 2022 11:29:48 +0530 Subject: [PATCH] repeatation of dot symbol/added new function --- script.js | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) 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