containsWhitespace
Returns true
if the given string contains any whitespace characters, false
otherwise.
Use RegExp.prototype.test()
with an appropriate regular expression to check if the given string contains any whitespace characters.
typescript
const containsWhitespace = (str: string) => /\s/.test(str);
typescript
containsWhitespace("lorem"); // false
containsWhitespace("lorem ipsum"); // true