Apply Functional Programming to Convert Strings to URL Slugs --- global variable test not passed

Tell us what’s happening:

global variable is not changing in the console, but it keeps on telling me that it is changing, I’ve tried searching similar topics, but no use. is this a problem with the freeCodeCamp itself?

Your code so far

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

// Add your code below this line
function urlSlug(title) {
  //return title.split(/\W/).filter(x => x!="").join("-").toLowerCase();
  return title.split(/\W/).filter((obj)=>{
    return obj !=='';
// 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/71.0.3578.98 Safari/537.36.

The code after // is what I have written , and the other solution below that is given by the freeCodeCamp itself. well both are similar…

learn-freecodecamp-org --> javascript-algorithms-and-data-structures --> functional-programming --> apply-functional-programming-to-convert-strings-to-url-slugs.

Can’t post the link, Sorry :frowning:

Are you sure you don’t have manually changed the global variable by mistake?

the extra space at the beginning looks suspicious:

var globalTitle = " Winter Is  Coming";

Your code looks correct, it may just be the global variable itself to be “wrong” :slight_smile:

Stop using var ! :slight_smile:

Go see MDN documentation :slight_smile: about let and const

Yeah, thanks, My bad :sweat_smile:
I was testing other test cases, so i changed it.