How can i Clean a value one by one in JavaScript? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

How can i Clean a value one by one in JavaScript?

Supposes i have "input type" value in Html "hello" and i get it's value to JavaScript and i want to clean hello on pressing Button but only one Alphabet be removed example <button onclick="myfun()">clean</button> hello 1.hell 2.hel 3.he 4.h null Explain it in simple way with a example.

21st Feb 2018, 5:56 AM
🦋FEATHER🦋
🦋FEATHER🦋 - avatar
7 Answers
+ 3
@Yasser button must be there and actually i want to make a programming in which if i click the button it would remove one Alphabet like "hello" if i click the button the result should be "hell" if i click once more the result should be "hel" and like this it would run till the word become null. i hop you get it.
21st Feb 2018, 12:02 PM
🦋FEATHER🦋
🦋FEATHER🦋 - avatar
+ 3
first of all thanks a lot😊 its all because of you i will be able to complete my project.
22nd Feb 2018, 3:58 PM
🦋FEATHER🦋
🦋FEATHER🦋 - avatar
+ 2
@Yasser you made it but just a little more change has to be done can you clean only the letter's present into the "input id" box . See i want to make a button which work like as in phone when we write something wrong on click the button it cleans one by one Alphabet's .
22nd Feb 2018, 5:12 AM
🦋FEATHER🦋
🦋FEATHER🦋 - avatar
+ 2
O yes @Yasser Brilliant man and thats i want.
22nd Feb 2018, 3:37 PM
🦋FEATHER🦋
🦋FEATHER🦋 - avatar
+ 2
what is the work of "use strict" value which you given on the function.
22nd Feb 2018, 3:42 PM
🦋FEATHER🦋
🦋FEATHER🦋 - avatar
+ 2
myInput.value = myInput.value.slice(0, -1); "can you explain me little this please."
22nd Feb 2018, 3:44 PM
🦋FEATHER🦋
🦋FEATHER🦋 - avatar
+ 2
By the way @Yasser i can understand you and your comments nicely 😊 .
22nd Feb 2018, 4:01 PM
🦋FEATHER🦋
🦋FEATHER🦋 - avatar