The output trims the white space but for some reason it doesn’t pass the test. Perhaps its due to the regex ?
Your code so far
// The global variable
var globalTitle = " Winter Is Coming";
// Only change code below this line
function urlSlug(title) {
return title
.trim()
.toLowerCase()
.split(/\b\W/)
.join('-') // output is 'winter-is-coming' but doesn't pass test
}
// Only change code above this line
var winterComing = urlSlug(globalTitle); // Should be "winter-is-coming"
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.132 Safari/537.36
.
Challenge: Apply Functional Programming to Convert Strings to URL Slugs
Link to the challenge:
https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/functional-programming/apply-functional-programming-to-convert-strings-to-url-slugs