I made a calculator. I feel like I made it overcomplicated

I made a calculator. I feel like I made it overcomplicated
0

#1

Hey Campers!

I just finished the Javascript Calculator beta version. I don’t want to pass the url to the challenge map before getting some feedback and possibly fixing bugs you’ll find. I feel like I made it a bit overcomplicated with too much logical operators in if statements.

Anyway, I hope you like it :slight_smile:

Cheers!
Sebastian


#2

Looks nice! There a few thing though:

  • After you have calculated an answer, you can always add a decimal point(also when there is already one in the answer)
  • After you have calculated an answer, you can add any number to the result, but not a zero.
  • The text is selectable, so clicking several times quickly on one button will select the text.

BTW: Your code is absolutely not overcomplicated. You don’t even need 100 lines of code. I am at 400 lines of code and not really finished yet…


#3
  • You can have several decimals in input numbers (1.2.3.)
  • You can’t input more than one zero (e.g. can’t input 100)
  • Looks like “clear-entry” only works if a result is showing

#4

Looks like “clear-entry” only works if a result is showing

Well, i saw different Clear Entry buttons. I don’t remember how it works on a real calculator, haven’t had such “equipment” for very long time. :smiley: I thought it should delete the everthing that was input since last evaluation.

// I think i fixed most of the bugs you mentioned guys. :slight_smile:


#5

400 lines of javascript in your calculator? Would you mind sending over the url ? :smiley:

The text is selectable, so clicking several times quickly on one button will select the text.

I have no idea how to fix this :confused: . Have you found a solution for that in your own project?


#6

Basic calculations should work (including use of brackets).

repo: https://github.com/BenGitter/JavaScriptCalculator
gh-pages: https://bengitter.github.io/JavaScriptCalculator


#7

For making text unselectable:

body{
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  -khtml-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  cursor: default;
}

http://stackoverflow.com/questions/2310734/how-to-make-html-text-unselectable


#8

Yeah, i kind of expected to see more buttons than in mine :smile:


#9

Haha, but I still need to add the logic for most of the buttons…