throw error in handleInput

This commit is contained in:
Andrzej Stepien 2023-07-04 17:13:24 +02:00
parent 15e2006548
commit 8e12725629
1 changed files with 5 additions and 1 deletions

View File

@ -22,10 +22,14 @@ export default function Calculator(props){
if(typeof content === "number" ){ if(typeof content === "number" ){
setMain(prev=>{return prev.toString()+content.toString()}) setMain(prev=>{return prev.toString()+content.toString()})
}else{ //EXTRA CONDITION FOR DECIMAL, REGEX TO MAKE IT MAKE SENSE }else if(content == "."){
//HANDLE DECIMAL WITH REGEX
}else if(operations[content]){
setMemory(prev=>{operations[content](prev,main)}) setMemory(prev=>{operations[content](prev,main)})
setMain(0) setMain(0)
setOperation(content) setOperation(content)
}else{
throw new Error("Parameter is not a number, '.' or operator.")
} }
} }