diff --git a/calculator/index.html b/calculator/index.html new file mode 100644 index 0000000..30ba1ab --- /dev/null +++ b/calculator/index.html @@ -0,0 +1,50 @@ + + + + + + + Calculat + + + + +

Calculatoo

+
+
+
+
+
+ + + + +
+
+ + + + +
+
+ + + + +
+
+ + + + +
+
+ + + + +
+ + + + \ No newline at end of file diff --git a/calculator/script.js b/calculator/script.js new file mode 100644 index 0000000..d698a28 --- /dev/null +++ b/calculator/script.js @@ -0,0 +1,19 @@ +let string = ""; +let buttons = document.querySelectorAll('.button'); +Array.from(buttons).forEach((button)=>{ + button.addEventListener('click', (e)=>{ + if(e.target.innerHTML == '='){ + string = eval(string); + document.querySelector('input').value = string; + } + else if(e.target.innerHTML == 'C'){ + string = "" + document.querySelector('input').value = string; + } + else{ + console.log(e.target) + string = string + e.target.innerHTML; + document.querySelector('input').value = string; + } + }) +}) \ No newline at end of file diff --git a/calculator/utils.css b/calculator/utils.css new file mode 100644 index 0000000..0a97292 --- /dev/null +++ b/calculator/utils.css @@ -0,0 +1,32 @@ +.text-center{ + text-align: center; +} +.row{ + display: flex; + align-items: center; + justify-content: center; + padding: auto; + +} +.purple{ + display: flex; + justify-content: center; + align-items: center; + background-color: rgb(137, 38, 231); +} + +.button{ + margin: 0 6px; + padding: 10px; + border: 2px solid black; + border-radius: 60px +} +.flex{ + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; +} +.row{ + margin: 6px 0; +}