javascript remove period from end of string

Solutions on MaxInterview for javascript remove period from end of string by the best coders in the world

we are a community of more than 2 million smartest coders
registration for
employee referral programs
are now open
get referred to google, amazon, flipkart and more
register now
  
showing results for - "javascript remove period from end of string"
Charlotte
20 Nov 2018
1// Single dot:
2if (str[str.length-1] === ".")
3    str = str.slice(0,-1);
4// Multiple dots:
5while (str[str.length-1] === ".")
6    str = str.slice(0,-1);
7// Single dot, regex:
8str = str.replace(/\.$/, "");
9// Multiple dots, regex:
10str = str.replace(/\.+$/, "");