I have a string that is typically a url (minus the http/www part). Keep in mind this string is returned via an API and not parsed from the browser url.
For eg "xyz.abc.com or "login.xyz.abc.com"
Now I need to parse the string and return only the subdomain so that I get the following:
"xyz" and "login.xyz"
With Python, I can achieve this using the following code:
".".join(String.split(".")[:-2])
I am unable to find the appropriate syntax or equivalent in javascript.
google.co.uk