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:
Simple Array Sum | Javascript | hackerrank.com07-05-2020 hackerrank.com javascript arrays array sum |
Compare the Triplets | Javascript | hackerrank.com07-05-2020 hackerrank.com |
How to search text in string using php ?29-10-2017 php search string search |
How to submit form using javascript or jquery.16-04-2017 javascript jquery submit form |
Get previous date from given date in javascript06-03-2017 date javascript previous date |