Created
March 16, 2023 14:34
-
-
Save solanoize/73a7aa1fca1080bdd7ae345ddccdbf3b to your computer and use it in GitHub Desktop.
Yuhu
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var buttonEqual = document.querySelector(".equal"); | |
| var buttonDelete = document.querySelector(".delete"); | |
| var inputText = document.querySelector(".output"); | |
| var actions = document.querySelectorAll(".action"); | |
| var clear = document.querySelector(".clear"); | |
| let evals = []; | |
| buttonEqual.addEventListener("click", function () { | |
| let evaluate = inputText.value; | |
| let result = Function(`return ${evaluate}`); | |
| inputText.value = result(); | |
| }); | |
| buttonDelete.addEventListener("click", function () { | |
| inputText.value = 0; | |
| evals = []; | |
| console.log(evals); | |
| }); | |
| clear.addEventListener("click", function () { | |
| evals.pop(); | |
| inputText.value = evals.join(" "); | |
| }); | |
| for (var i = 0; i < actions.length; i++) { | |
| actions[i].addEventListener("click", function (e) { | |
| evals.push(e.target.innerHTML); | |
| inputText.value = evals.join(" "); | |
| }); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment