Disallow whitespace from string jquery


                var is_subdomain = 'CHeck io.com';
                if(!is_subdomain.split('.')(0).slice(-1) !== "-" || pattern.test(domain) == false)  {
                  console.log('ok');
                 }

How do i disallow whitespace from string jquery ?