Functional Programming: Apply Functional Programming to Convert Strings to URL Slugs - problem?

Hi,
on https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/functional-programming/apply-functional-programming-to-convert-strings-to-url-slugs
page I have instantly following error:

// running tests The

globalTitle

variable should not change. // tests completed // console output Winter Is Coming winter-is-coming

even if I insert solution from “hints” :

// The global variable
var globalTitle = " Winter  Is Coming";
// Only change code below this line
function urlSlug(title) {
  return title
    .split(/\W/)
    .filter(obj => {
      return obj !== "";
    })
    .join("-")
    .toLowerCase(); 
}
// Only change code above this line
var winterComing = urlSlug(globalTitle); // Should be "winter-is-coming"
console.log(globalTitle,winterComing);

What could be wrong?

While writing this, I found the solution here:
[Functional Programming: Apply Functional Programming to Convert Strings to URL Slugs](http://Functional Programming: Apply Functional Programming to Convert Strings to URL Slugs)
I have changed the initial value of the variable, when I checked the “first hyphen” issue. The testing software could catch these situations… Also would be nice to have console.log() output in all exercises, because I ususally add it, to see the output.

globalTitle is incorrect from very beginning, there are couple extra whitespaces

1 Like

when there is a line like this you risk failing if you do not respect it

1 Like

Yes, but I wanted to trace solution of another problem - with extra hyphen in the beginning of the returned string. So I changed the input string, and finally forgot about that change…

Yes, finally I found it. I chaged the input string to test another problem, and forgot about it. Thanks.

you can always add a new function call, if there is written you can’t change something