One simple approach you could take is to compare the length of the original string with that of the string to have whitespaces replaced with nothing. For example:
function hasWhiteSpaces(string) {
if (string.length == string.replace(" ", "").length) {return false}
return true
}