diff --git a/calculator-app/index.html b/calculator-app/index.html new file mode 100644 index 000000000..234b5da96 --- /dev/null +++ b/calculator-app/index.html @@ -0,0 +1,39 @@ + + + + Calculator + + + + +
+ + +
+ + + + + + + + + + + + + + + + + + + + + +
+
+ + + + \ No newline at end of file diff --git a/calculator-app/script.js b/calculator-app/script.js new file mode 100644 index 000000000..3b5502589 --- /dev/null +++ b/calculator-app/script.js @@ -0,0 +1,21 @@ +let display = document.getElementById("display"); + +function press(val) { + display.value += val; +} + +function calculate() { + try { + display.value = eval(display.value); // (ok for practice) + } catch { + display.value = "ERR"; + } +} + +function clearAll() { + display.value = ""; +} + +function clearLast() { + display.value = display.value.slice(0, -1); +} \ No newline at end of file diff --git a/calculator-app/style.css b/calculator-app/style.css new file mode 100644 index 000000000..4399b4896 --- /dev/null +++ b/calculator-app/style.css @@ -0,0 +1,15 @@ +body { + font-family: Arial; + text-align: center; +} + +.calculator { + width: 200px; + margin: auto; +} + +button { + width: 40px; + height: 40px; + margin: 2px; +} \ No newline at end of file