Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code Enhancement #30

Open
Hajer3349 opened this issue Aug 19, 2023 · 3 comments
Open

Code Enhancement #30

Hajer3349 opened this issue Aug 19, 2023 · 3 comments

Comments

@Hajer3349
Copy link

Hello, I noticed that the input space of the calculator after getting the result and clicking any number is not cleared, it stays there and the clicked number is displayed as an additional digit to the input value.

I suggest altering the adder function in cal.js file to the following code:

Before
- function adder(k){
valEl.innerText += k
if(k=='*' || k=='+' || k=='-' || k=='/'){
compute(0)
}
}


After
+ function adder(k){
    
    if (/\d/.test(k)) {
    if (resEl.innerText[0] == '=') {
        valEl.innerText = ""
        resEl.innerText = ""
    } }
    
    valEl.innerText += k 

    if(k=='*' || k=='+' || k=='-' || k=='/'){
        compute(0)
        if (resEl.innerText[0] == '=') {
            resEl.innerText = ""
        }
    }
}

Please let me know if you want me to add these changes, thank you.

@Babuprasanth27
Copy link

hey, I am interested in fixing this issue. And explain what exactly I have to fix the issue.

@Babuprasanth27
Copy link

i have the solution for this

@Hajer3349
Copy link
Author

@Babuprasanth27 You can follow the code I suggested in the snippet or you're free to come up with your own solution of course

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants