Map() method is unacceptable

Tell us what’s happening:

I got the same output using map() method, but the validator doesn’t accept it. Why is this happening?

Your code so far


// The global variable
var globalTitle = "Winter Is Coming";

// Only change code below this line
function urlSlug(title) {

return title.split(/\W/).map(word => word.toLowerCase()).join("-")

}
// Only change code above this line
console.log(urlSlug(globalTitle));

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:74.0) Gecko/20100101 Firefox/74.0.

Challenge: Apply Functional Programming to Convert Strings to URL Slugs

Link to the challenge:

Take a closer look at the specific case that is not passing. Try:

console.log(urlSlug(" Winter Is   Coming"));
1 Like

Got it. Changed map to filter. It works. Thank you!