If we want to remove last two characters from given string. There is an simple method in javascript, i.e substring.
var name = "hi hellow"; name.substring(0, name.length - 2);
the result is : hi hell
Note: The substring() method does not change the original string.
The actual substring syntx is
string.substring(start, end)
You might also like:
A Very Big Sum | Javascript | hackerrank07-05-2020 A Very Big Sum Javascript hackerrank |
Time Sorting Ascending or Descending Order in Javascript19-07-2017 Javascript ascending order descending order |
How to convert html to pdf in Node js12-03-2017 pdf convert html node js |
How to get current date and time (yyyy-mm-dd H:i:s) using javascript09-03-2017 javascript date time |
Get random strings from given string In javascript21-02-2017 javascript random string |