Hi All,

I’ve been trying to complete the Javascript calculator code, but I keep failing on test 13::

## If 2 or more operators are entered consecutively, the operation performed should be the last operator entered (excluding the negative (-) sign.

What is the best way to solve this

Here is my codepen:

Thanks!!!

Teller
2
Hi @mirajhaq

The code will fail as it only allows one operator at a time.

You need to refactor so that if more than one operator is input, the first operator is ignored and second operator is accepted.

**Unless** the second operator is the minus sign, then accept both operators.

So:

5 / + 5 becomes five plus five = ten

5 + - 5 becomes 5 plus negative five = 0

5 * - 5 becomes five times negative five = negative twenty five

Also two decimal points in a row will fail the tests.

Happy coding