Question: I am creating a javascript calculator and I am stuck. How can I clear the calculator result (answer) in the textbox so that another input

I am creating a javascript calculator and I am stuck. How can I clear the calculator result (answer) in the textbox so that another input click by the user will only show the number that was clicked, ex: say the answer showing is 3.00, if the user clicks the number 4 button or any other number button, I need it to clear out the 3.00 (answer) and only display the number 4 or whatever number button was clicked so they can input a new formula to be calculated. currently, once i get the answer, if i click on any of the number buttons, it just adds that number to the answer, for ex: say the answer is 3.00 and I click the number 4, it will display as 3.004.

the following is my code:

calculator.js -

window.addEventListener("load", function() { document.getElementById("convertBtn").addEventListener("click", convert); //will get all button values var numbers = document.getElementsByClassName("digit"); var size = numbers.length; //gets length of array of numbers/button values //loops through and adds an event listener to each of the buttons for (var i = 0; i

and my html code is below:

calculator.html -

Calculator

JS Calculator

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!