The idea here is to start from 0 and keep all the letters except the last one. '\t Hello, World\t \n\n'.trim (); // 'Hello, World'. Remove last character from string javaScript