+ 1

Calculator delete button?

So I wrote this simple calculator. Is there a way to add a delete button so I can delete the last value entered? Ex: 1+1 *presses delete button* 1+ https://code.sololearn.com/WXCWgM8w0cjz/#html

1st Jun 2018, 12:02 AM
Daniel Cooper
Daniel Cooper - avatar
7 Respostas
+ 7
Just add <td><input class="button" type="button" value="DEL" onclick="calculator.display.value = calculator.display.value.substr(0,calculator.display.value.length-1)"></td>
1st Jun 2018, 12:41 AM
Tiger Jones
Tiger Jones - avatar
0
Thanks. And since i'm very new to coding, I was wondering what the "0," means.
1st Jun 2018, 12:57 AM
Daniel Cooper
Daniel Cooper - avatar
0
this means that you create a new string with the same characters except for the last one.
1st Jun 2018, 10:47 AM
Tiger Jones
Tiger Jones - avatar
0
Now what would be the result if I were to put a 1 there instead? I guess I could have found out myself before typing this, but i'll send it anyway. xD
1st Jun 2018, 10:56 PM
Daniel Cooper
Daniel Cooper - avatar
0
You then would also remove the first character.
2nd Jun 2018, 2:26 PM
Tiger Jones
Tiger Jones - avatar
0
Lol. I figured it out yesterday. Thanks though
2nd Jun 2018, 6:26 PM
Daniel Cooper
Daniel Cooper - avatar
0
I need help with it.
2nd Sep 2022, 5:35 PM
Treasure Ojeamiren
Treasure Ojeamiren - avatar