RegExp.prototype.test()
with an appropriate regular expression to check if the given string contains any whitespace characters.const containsWhitespace = str => /\s/.test(str);
containsWhitespace('lorem'); // false
containsWhitespace('lorem ipsum'); // true
Subscribe to get resources directly to your inbox. You won't receive any spam! ✌️