Hello,
Can someone please help me out of my current state of stuck-ness? I believe that my problem is in not being able to specify exactly how I want to split the string into my variable array with whitespace in mind. That is, how can I target the whitespace at the beginning, middle, and end of a given string so that when I use split() on the string, the resulting array “ignores” ALL whitespaces? Apologize if I’m unclear/unnecessarily verbose/etc.
// the global variable
var globalTitle = "Winter Is Coming";
// Add your code below this line
function urlSlug(title) {
let lowCase = title.toLowerCase();
let newArr = lowCase.split(/\s+/);
console.log(newArr.join("-"));
return newArr.join("-");
}
// Add your code above this line
var winterComing = urlSlug(globalTitle); // Should be "winter-is-coming"