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.