Ready to bang my head against the wall! JS Calculator problems

At this point, I am frustrated and ready to bang my head against the wall. But I don’t want to give up and abandon my JS Calculator. I’ve been working on this problem the past few days and have gotten few helps and tips from FreeCodeCamp chat and Stackoverflow to bring me this far but not enough to solve this problem.

The problem I’ve been working on is repeating operators. For example, if I press “5” and then “+”, but changed my mind and pressed “-”, the history area should display “5-” instead of “5+”.

In my original code at this Original JS Calculator Codepen, everything else works fine. However, in this codepen, If I press “5” and “+”, but then press “-”, the history display “5+0-”.

I was able to fix this problem in this Forked JS Calculator 3 Codepen. However, it created even more problems. For example, if I use multiply mathematical operations like “1+2+3”, the history display doesn’t work properly.

At this point, I just want someone to write the solution so that I can see what I overlooked or didn’t think about.

Also I have added console.log to most statements in my code. It’s to help me figure out what’s wrong with my code. I will clean it up once I fix all the problems found…

Btw, all the action is happening in function addOperator(keyitem)

Looking forward to solutions so that I don’t need to bang my head against the wall… T_T