Tell us what’s happening:
My code passes all the tests except one: “the globalTitle variable should not change.” I’m having trouble understanding why this one test fails; It works perfectely in my console but it doesn’t work on FCC. Isn’t a string passed by value to a function or is that wrong? I’ve tried creating a local copy of the string and that failed on FCC as well. Can someone please explain this to me? Thanks and I would appreciate the help.
Your code so far
// the global variable
var globalTitle = " Winter Is Coming";
// Add your code below this line
function urlSlug(title) {
return title.trim().split(/\s+/).join('-').toLowerCase();
}
// 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/67.0.3396.79 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