Apply Functional Programming to Convert Strings to URL Slugs error

Tell us what’s happening:
Hi guys, another post from me :smiley:
Just simple question; why i cant pass test with this code? Error message: The global Title variable should not change. I think i dont change it anywhere in my code cause when i console.log() global title after function executes it does not change but maybe im wrong. Can someone please explain this error to me?

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(' ').filter(item => (item !== '')).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 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130 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

Originally the global variable was:

var globalTitle = "Winter Is Coming";

You have:

var globalTitle = " Winter Is  Coming";

It appears to contain at least two extra spaces.

1 Like

Oh yes, i just pasted this for testing and forgot about it. Thanks, that was kind of embarassing :smiley:

It happens :wink: