Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Java by (9.5k points)

Can anyone tell me how to delete the first character of a string that is zero and delete it in JavaScript?

1 Answer

0 votes
by (19.7k points)

Check the code below to remove 1st character of a string using substring:

var s1 = "foobar";

var s2 = s1.substring(1);

alert(s2); // shows "oobar"

See the code snippet below to remove all 0’s:

var s = "0000test";

while(s.charAt(0) === '0')

{

 s = s.substring(1);

}

Interested in Java? Check out this Java tutorial by Intellipaat. 

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

Browse Categories

...