Check if a string contains whitespace
JavaScript version
const containsWhitespace = (str) => (str) => /\s/.test(str);
TypeScript version
const containsWhitespace =
(str: string): boolean =>
(str) =>
/\s/.test(str);
Examples
containsWhitespace('hello world'); // true