Apply Functional Programming to Convert Strings to URL Slugs issue with globalTitle

Tell us what’s happening:
When running the below code it states that it satisfies all the requirements for this lesson except that globalTitle does not change. As far as I can tell I’m never changing that variable and when I console.log(globalTitle) it it states what was originally put in. Am I missing something?

Your code so far

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

// Add your code below this line
function urlSlug(title) {
  let a = title.toLowerCase()
  let x = a.trim()
  let b = x.split(/\s+/)
  return b.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/71.0.3578.98 Safari/537.36.

Link to the challenge:

In your code above, globalTitle has a bunch of spaces in it that weren’t there originally.

1 Like

That was it thank you

Since you’re going with useless variable names,. why not just chain those methods together instead?