Skip to content

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

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.