Length Of Last Word in a String | Javascript program for implementation of efficient approach to find length of last word ; Split by space and converting String to list and ; Driver code
function length ( str ) { var lis = str . split ( " " ) return lis [ lis . length - 1 ] . length ; } var str = " " document . write ( " " + length ( str ) ) ;