1、 use the indexOf method on the input string:
function hasWhiteSpace(string) {
return string.indexOf(' ') >= 0;
}
2、use the test method, on a simple RegEx:
function hasWhiteSpace(string) {
return /\s/g.test(string);
}
1、 use the indexOf method on the input string:
function hasWhiteSpace(string) {
return string.indexOf(' ') >= 0;
}
2、use the test method, on a simple RegEx:
function hasWhiteSpace(string) {
return /\s/g.test(string);
}