I am trying to use regular expressions to handle more than one operators but it doesn’t seem to work. Here is the link to my codepen: https://codepen.io/ambarish-gokhale/pen/RwWBKKa
Please help!
I am trying to use regular expressions to handle more than one operators but it doesn’t seem to work. Here is the link to my codepen: https://codepen.io/ambarish-gokhale/pen/RwWBKKa
Please help!
It is because you haven’t coded the calculator to do what is expected. The error message is very clear.
If 2 or more operators are entered successively, the operation performed should be the last operator (excluding the negative sign)
Your calculator should be able to interpret computations such as:
2 * + 4 = 2 + 4
1 + * /2 = 1 / 2
5 + - * 6 = 5 * 6
5 * + -6 = 5 + -6
You need to work on it to ensure such calculations can be performed.
What did I do wrong? Or where in my code should I correct it?