i’ve pasted the handler below. I’m passing the “f” test as evidenced by console.log
beyond that NOTHING changes. I think it has something to do with the way I’m setting the state because even if i change the display state to a simple string… it doesn’t update.
here’s my full code link
handleOp = (e) => {
//error test
// console.log('handleOp START/ e= ', e, 'negOn = ', this.state.negOn, 'opOn = ', this.state.opOn, 'e is not a number: ', isNaN(e), 'e != -', e != '-')
//error test
if(this.state.opOn === true && isNaN(e)){
console.log('this.state.opOn === true && isNaN(e))')
//when a 2nd opperator is passed in a row but it's not '-'
//the calculator must use the most recent operator
//set myfNum to current state.fNum
myfNum = 'this is working' //this.state.fNum;
//remove the last element in the fNum string. This is the original operator
myfNum = myfNum.slice(0, myfNum.length-1);
//add the new operator to the fNum string
myfNum = myfNum + e;
//set sNum to current state.sNum
mysNum = [...this.state.sNum];
//remove the last element from the sNum array
mysNum = mysNum.splice(0, mysNum.length-1);
//add the new operator being passed to the sNum arry
mysNum = [...mysNum, e];
//eq is not on //will not update
myeqOn = false;
//opOn remains true
myopOn = true;
//a '-' was not the last operator to be passed
//updates state.display to the new operator
myDisplay = e;
myDotOn = false;
myNegOn = false;
this.setState ({
fNum: myfNum, // myfNum, //string that stores the top display row
sNum: mysNum, //array that stores numbers and operators which will be used at the equals
eqOn: myeqOn, //stops additonal input after equals sign has been pushed
opOn: myopOn, //stops eq from firing or additional operators from being added when operator is in display
display: myDisplay, //string that stores the bottom display row
dotOn: myDotOn, //insures that the dot can't be pressed twice
negOn: myNegOn
})
}