Huh, i guess js calculator is the hardest project in the front-end course

i mean i haven’t made the clock, and the two games yet but i think they should be much simpler, calculator needs an awful lot of logic to handle inputs (no zero two times unless there is a non zero digit, no double or starting dot, no too long numbers, handling incomplete operation strings etc) and especially outputs since js is not very convenient to work with numbers and you should avoid getting your output windows overflowing so they should be either rounded to exactly fill the window or made into e10 format, truncating trailing zeros, truncating the line of operations waiting to be executed (can’t even do it with css because the numbers appear on the right, should be truncated on the left but the reading order is still left to right, so i had to use a monospace font again instead of cool “orbitron”…) etc etc. my script took 474 lines of code, lol

also the task to make a button whose height encompasses two button rows i.e. the “=” button was a surprisingly hard css task, hardest to me in this course yet, which also taught me not to use bootstrap stuff when non needed… including the useless bootstrap buttons, i dunno why they even exist when it’s easy to draw your own buttons and it’s a pita to remake bootstrap’s buttons removing hover etc effects from them

here is my calc, i have tested it to avoid overflowing and to behave properly but it’s pretty possible i still missed something, probably even very simple… the order of executions is immediate like on the standard win calculator or on the sample calculator from the project page. could be make better ofc, for instance adding backspace and +/- etc

p.s. lol, running it just now i realized i forgot to make current input truncate traling zeros, i mean if you enter something like 1 + 4.0000 and then press another + it will truncate it to 1 + 4 + in the input string (small numbers) but the current input (large numbers) will be still 4.0000, but i guess it’s probably even better that way, i might make it show the intermediate result like on the win calc but i guess it’s a bit confusing and zero truncating might be confusing too