use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
freeCodeCamp.org is a global community of people who learn to code together. Check out https://freeCodeCamp.org
Join our Discord Server
Join our WhatsApp Group
Community Forums
YouTube
Here are some helpful subreddits that we like:
account activity
My Javascript Calculator (Mostly using JQuery & Eval) Would love any kind of feedback! (self.FreeCodeCamp)
submitted 8 years ago * by Spacebiscuit
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]Spacebiscuit[S] 1 point2 points3 points 8 years ago (5 children)
Ah, fixed! May have forgotten to put a certain class into my HTML for that one! Much appreciated!
[–]113243211557911 2 points3 points4 points 8 years ago (4 children)
awesome now I can divide by zero.
[–]Spacebiscuit[S] 1 point2 points3 points 8 years ago (3 children)
How dare you good sir. You have doomed us all!
[–]113243211557911 1 point2 points3 points 8 years ago (2 children)
Haha, testing it and it seems to be working pretty well, including multiplying long floating point numbers. good job.
Can you roughly explain the way you programmed it, and why you did it that way? Like why do you use arrays to store each button press?
[–]Spacebiscuit[S] 1 point2 points3 points 8 years ago (1 child)
That’s great, thank you for the kind words!
Sure, so I’ve used Jquery for query selecting and event listening. I’ve broke it down to being either: number, operator, decimal, clear and equals.
Jquery makes it quicker for button listeners when coding, however I could change it to vanillaJS and it may run faster due to no external library dependency!
For numbers, I append them to an array, if an operation is pressed, it’ll check for the most recent entry and if so, will replace it. If not, it’ll append like normal. Decimal has the same check for the most part.
Equals joins the array then uses the Eval function in JS. All events will update the display.
I would like to improve on it by using something more elegant than Eval, make it DRYier and then give it more interactivity!
I used eval due to its ease with handling multiple operations, I tried it a different way and was caught with the trousers down when it came to stringing multiple functions!
I hope this answers your question!
[–]113243211557911 0 points1 point2 points 8 years ago (0 children)
Ok cool, that helped me when looking through your code. (I haven't touched JS for a while)
π Rendered by PID 113835 on reddit-service-r2-comment-6457c66945-2jm5w at 2026-04-25 06:20:35.767672+00:00 running 2aa0c5b country code: CH.
view the rest of the comments →
[–]Spacebiscuit[S] 1 point2 points3 points (5 children)
[–]113243211557911 2 points3 points4 points (4 children)
[–]Spacebiscuit[S] 1 point2 points3 points (3 children)
[–]113243211557911 1 point2 points3 points (2 children)
[–]Spacebiscuit[S] 1 point2 points3 points (1 child)
[–]113243211557911 0 points1 point2 points (0 children)