Functional Programming: Apply Functional Programming to Convert Strings to URL Slugs - my solution

My solution to this challange:

// the global variable

var globalTitle = "Winter Is Coming";

// Add your code below this line

function urlSlug(title) {

return globalTitle.split(" ").map(val =>; val.toLowerCase()).join("-");

}

// Add your code above this line

var winterComing = urlSlug(globalTitle); // Should be "winter-is-coming"

Can anybody tell me what is wrong with my code? I’ve tested it in the Chrome’s console and it works just fine.

Hey! Thanks for helping me out. I haven’t spotted that - it’s my silly mistake.

Now, my adjusted and working solution is:

function urlSlug(title) {

return title.split(" ").map(val => val.toLowerCase()).filter(val =>

val.length > 0).join("-");

}

Thanks again! Cheers!
Szymon