Front End Development Libraries - Build a JavaScript Calculator

Hello, im stuck with Test 13. CodePen Home Javascript Calculator

My latest try was to use a for Loop and it kinda works with the 5*-+5 calculation. If i type it in like that, the for loop transforms it into 5+5, which is 10. So i cant get to the result -25. But the test says the outcome is still -25. Any tips?

Hi @daniel.krafzik

With 5*-+5 the negative sign is disappearing from the calculation.

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

So you need to include logic when the negative sign is entered.

5 + - 5 in words is five plus negative five

Also, the operator is the last operator entered.

5 * * 5 should equal twenty five, not 3125

Happy coding

1 Like

Wow, the Test message was really confusing for me. With your hint i got now in like 2 Minutes. THANK YOU!

1 Like