diff --git a/index.html b/index.html index 9f62b48..6495afd 100644 --- a/index.html +++ b/index.html @@ -4,7 +4,7 @@ - Document + Scientific Calculator @@ -23,11 +23,18 @@

Scientific Calculator

+ + + + + +
+
+ -
diff --git a/script.js b/script.js index 77283ff..f3b6226 100644 --- a/script.js +++ b/script.js @@ -23,7 +23,6 @@ function clearData() { //------------------ NUMBER -------------------------- function number(value) { - data.staging = []; data.staging.push(value); result.value = data.staging.join(''); console.log(data); @@ -305,12 +304,18 @@ function parenthesesOpen() { data.staging = []; operation.value = data.formats.join(''); result.value = data.result; - } else if (data.staging.length === 0 && isNaN(parseFloat(data.operations[data.operations.length - 1]))) { + } else if (data.staging.length === 0 && isNaN(parseFloat(data.operations[data.operations.length - 1])) && data.operations[data.operations.length - 1] !== ")") { data.operations.push('('); data.formats.push('('); data.staging = []; operation.value = data.formats.join(''); result.value = data.result; + }else if (data.staging.length === 0 && data.operations[data.operations.length - 1] === ")"){ + data.operations.push('*', '('); + data.formats.push('×', '('); + data.staging = []; + operation.value = data.formats.join(''); + result.value = data.result; } console.log(data); }