Goal would be to get one subdomain and swap it out for another. I feel there has to be a cleaner way to do this. help me out!
var url = window.l...
For further actions, you may consider blocking this person and/or reporting abuse
This is using a regex, but at least it is a small one.
^
[^
.
.
]
+
.
)\.
.
gorgeous! I love me some regex. I was trying to do this yesterday but going about it all wrong. I was trying to abstract out the last part of the domain. Should have made it easy on myself and just find/replace the subdomain! Thank you!
Well, according to the documentation for slice, using a negative index will allow you start indexing from the end of the array rather than the beginning.
So
domainParts.slice(domainParts.length - 2, domainParts.length)
is equivalent todomainParts.slice(-2)
.Another thing is that since admin is a constant, you can add that when you are concatenating the string rather than manipulating the array.
Array.prototype.slice
aww yes! nice!