How to add Delete button to a calculator

40 Views Asked by At

Working on advanced calculator with JavaScript but the delete function is not working

input.value = input.value.slice(0, -1)

it was supposed to delete one value, but it just turned the entired input to a string and totally made my input invalid

1

There are 1 best solutions below

0
Brent On

Many different ways to do this, the first that comes to mind is doing this:

input.value = Number(input.value.toString().slice(0, -1));