Is there a way in JavaScript to remove the end of a string?
I need to only keep the first 8 characters of a string and remove the rest.
Use substring function
Check this out http://jsfiddle.net/kuc5as83/
var string = "1234567890"
var substr=string.substr(-8);
document.write(substr);
Output >> 34567890
substr(-8)
will keep last 8 chars
var substr=string.substr(8);
document.write(substr);
Output >> 90
substr(8)
will keep last 2 chars
var substr=string.substr(0, 8);
document.write(substr);
Output >> 12345678
substr(0, 8)
will keep first 8 chars
Check this out string.substr(start,length)