Delete trailing whitespace in javascript