length-1] . remove last character from string if a period if(str.charAt( str.length-1 ) alert( str.slice(0, -1) ) Well, finding that easily on a search would have saved me some time. Happy Coding! js>"12345.00".slice(0,-1) 12345.0. Compared to the accepted solution, this is way more elegant and can be used even with dynamically created strings.unconditionally removes the last 4 characters from string s. while leaving the rest as is. So you empty it when str is empty, but you fill it when the ajax call is made.