Tell us what’s happening:
I am not able to pass the test with the following error.
“The globalTitle variable should not change.”
But I believe none of method that I used is changing the original string. do you have any idea on this?
.toLowerCase() > returns a new string
.split() > returns a new array
.filter() > returns a new array
Your code so far
// the global variable
var globalTitle = " Winter Is Coming";
// Add your code below this line
function urlSlug(title) {
return title.toLowerCase().split(/\W+/).filter(x=>x.length>0).join("-")
}
// Add your code above this line
var winterComing = urlSlug(globalTitle); // Should be "winter-is-coming"
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.102 Safari/537.36
.
Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/functional-programming/apply-functional-programming-to-convert-strings-to-url-slugs