# Javascript calculator - 13pkt

Hi, I am working on JavaScript Calculator and i have problem with understanding pkt 13 when i am checking my app for bugs. It says:

"If 2 or more operators are entered consecutively, the operation performed should be the last operator entered (excluding the negative (-) sign. The sequence “5 * - + 5” = should produce an output of “10” : expected ‘-25’ to equal ‘10’ "

I do not understand why 5*-+5 should be 10? I would rather say that this equation is undefined or sth.

Its saying that the other operators should be ignored. The last operator is a “+”, so use only that for the calculation.

Yes, i know but why the last operator not first? Is it any special math use for that?

If you were to use a real physical calculator, often times it would work the same way. Imagine you put in 5, then * by accident, then decided instead you wanted to put in +. The physical calculator will just assume you want the last one entered since you were correcting your mistake before submitting the next number. I just tried it on my own calculator on my desk and it works this way.

1 Like

Thank you for your help i have just try my mobile phone calculator and when i pressed 5*-+5 it said “bad expression”. And i think that it is a better option but believe you that physical calculators will do it this different way. I have just never noticed that. Anyway Thank you for help.

2 Likes