Apply Functional Programming to Convert Strings to URL Slugs help needed!

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:

I would reset your code, but copy the function first.

I copied your function and passed all tests with no errors.

Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36

1 Like

Hi @addisonday yeah… it is weird. It is passing without a problem now…

Only for other campers with the same problem:

var globalTitle has to be the string that it was at the beginning of the exercise. :slight_smile: