Javascript examples for String Operation:String Remove
remove the last word from a string?
<html> <head></head> <body> <script> var str = "I am from 123 433." var res = ""; var spl = str.split(' '); var len = spl.length; for(var i=0; i<len - 1;i++) { if(i == len-2 ) res +=spl[i] +"."; else// w ww .j a va 2s . c om res +=spl[i] +" "; } console.log(res); </script> </body> </html>