javascript trim string to length