Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Web Technology by (47.6k points)

I have a string, 12345.00, and I would like it to return 12345.0.

I have looked at trim, but it looks like it is only trimming whitespace and slice which I don't see how this would work. Any suggestions?

1 Answer

0 votes
by (106k points)

You can use the substring function to chop/slice/trim off last character in string  in JavaScript see the code below:-

var str = "12345.00";

str = str.substring(0, str.length - 1); 

Related questions

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...