Build a JavaScript Calculator

Hey everyone,

I’m struggling to get my calculator to do the proper mathematical operations once I hit the equals button. Currently, when I hit equals, my calculator should be trying to evaluate a string that looks like this, for example: "333+222*4+111/4"

I was thinking about splitting that string into an array and then figuring out how to evaluate it that way, however, I’m having issues splitting it and maintaining the mathematical operators inside, in their proper order/locations.

I found a library online called math.js, it can take my mathematical string and evaluate it… Am I cheating using a library like this in my project?

using a library is always useful, but doing it on your own for learning purposes is gold!! i bet you already know that :slight_smile:

  • seems like a nice way to achieve this to me

happy coding :slight_smile:

1 Like