Quiero que mi calculadora muestre "0" cuando se borre o no se hayan ingresado otros números, pero cuando comience a agregar números, quiero que se reemplace el 0. Actualmente, cuando ingreso cualquier número, reemplaza el número en la pantalla por el número ingresado.
this.currentDisplay = "0" numberData(number) { if (number === "." && this.currentDisplay.includes(".")) return if (this.currentDisplay = "0") { this.currentDisplay = this.currentDisplay.toString().replace("0", number.toString()) } else { this.currentDisplay = this.currentDisplay.toString() + number.toString() } }Tiene un error en esta condición:
if (this.currentDisplay == "0") { ... } En su código, está asignando this.currentDisplay = 0 , debe comparar con == o mejor === para comparar los tipos de variables también.