Hi all,
I’ve managed to complete this challenge except for the fact that I’m failing the “The globalTitle
variable should not change.” I’m scratching my head here. What part of my code is changing the global variable?
// the global variable
var globalTitle = "Winter is Coming";
// Add your code below this line
function urlSlug(title) {
let slug = title.slice();
return slug.toLowerCase().split(/\W/).filter((item) => item.length > 0).join("-");
}
// Add your code above this line
var winterComing = urlSlug(globalTitle); // Should be "winter-is-coming"
Thanks in advance!
Link to challenge: https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/functional-programming/apply-functional-programming-to-convert-strings-to-url-slugs