Calculator delete button? | Sololearn: Learn to code for FREE!

+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

6/1/2018 12:02:44 AM

Daniel Cooper

7 Answers

New Answer

+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>

0

Thanks. And since i'm very new to coding, I was wondering what the "0," means.

0

this means that you create a new string with the same characters except for the last one.

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

0

You then would also remove the first character.

0

Lol. I figured it out yesterday. Thanks though

0

I need help with it.