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

Updated the code to use % operator #34

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

theDevSoham
Copy link

This PR fixes #31

The solution

  • In the calculate function in script.js firstly modified the regex you used to check for the % operator as well
  • I put a code in the same function to check if there's any number after %. If there's no number it'll return the % value of the number. That is it'll divide the number by 100. Else it's getting passed through the eval function which has inbuilt functionality for modulus operations
    Screenshot from 2023-10-06 11-22-52
    Screenshot from 2023-10-06 11-23-10
    Screenshot from 2023-10-06 11-23-36
    Screenshot from 2023-10-06 11-23-44

@theDevSoham
Copy link
Author

Hey @astush1001 , the latest commit applies the modification requested. Please check. Btw the * sign you see after the % is applied automatically when you press any number key after %. I saw similar functionality in google calculator

Screenshot from 2023-10-08 12-43-53
Screenshot from 2023-10-08 12-44-05

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

Successfully merging this pull request may close these issues.

Percentage (%) operation Not working
1 participant