How to remove last character of a string using #javascript ( #jQuery )

0 Shares
0
0
0
0
0
0
0

You can also try this in plain javascript

var str = "My Name is Tejash Shah!"
str.slice(0,-1) // Output = "My Name is Tejash Shah" Remove "!"
str.slice(0,-6) // Output = "My Name is Tejash" Remove " Shah!"

the negative second parameter is an offset from the last character, so you can use -2 to remove last 2 characters etc