Hey, I am working on the calculator project. I am runnng into a failing test because of decimals. Here is the error Im getting: `When the decimal element is clicked, a “.” should append to the currently displayed value; two “.” in one number should not be accepted.
An input of “5 . .0” should display 5.0: expected ‘5…0’ to equal ‘5.0’`
Here is the snippet of code im messing with to try and get it to work:
const onClick = (button) => {
switch (button) {
case "AC":
setOperations(["0"]);
break;
case "=":
calculateOperations();
break;
default:
const newData = update(operations, { $push: [button] });
const firstDigit = newData[0];
if (firstDigit === "0") {
newData.shift();
}
for (let i = 0; i < newData.length; i++) {
let noDecimal;
if (newData[i] === "." && newData[i + 1] === ".") {
noDecimal = [...newData.slice(newData[i], newData[i + 1])];
console.log(noDecimal);
}
}
setOperations(newData);
break;
}
};