To know if a string is composed of a word or two words [duplicate]

Trim the string and then check for space

var hasMultipleWords = input.trim().indexOf( " " ) != -1; //returns true if there is a space

Leave a Comment