How do I detect if a string has any whitespace characters?
The below only detects actual space characters. I need to check for any kind of whitespace.
var string = 'hello world'; var arr = string.split(''); // converted the string to an array and then checked: if(arr[i] === ' '){ console.log(i); }
I know regex can do the trick too!