Closed AustinTSchaffer closed 6 years ago
Added a check to make sure only one decimal point allowed.
decimalToInputActive = () => {
const stackVals = this.state.stack
let inputActive = stackVals[0]
inputActive = inputActive.toString()
if (inputActive.includes('.')) {
console.log("A . is already in the display.")
}
else {
inputActive = inputActive +'.'
this.setState({stack: [inputActive,...stackVals.slice(1)]})
console.log(inputActive)
}
}
There's no limits to the period key. Also, the values with extraneous periods will be parsed by the calculator. It almost looks like the values will be parsed up until the second period. In the example image, the result of adding
2....etc...0
and1.2..3...etc
is3.2
.It seems like there needs to be an additional check on the user's input that takes the current state into consideration, such as a count of the dot characters or a boolean flag that keeps track of the "dot state" of the current value.