Check if the given string contains any whitespace characters in JavaScript
const containsWhitespace = txt => /\s/.test(txt);
Advertisements
Examples
containsWhitespace("Hey hello"); // true containsWhitespace("Heyhello"); //false