Code failing at Convert Strings to URL Slugs

Hi all!

My code in this challenge is failing and I don’t understand why. It returns * The globalTitle variable should not change.* and it is not changing, as you can check in the console.log. Any clue of what is going on? Might it be a bug?

// the global variable
var globalTitle = "     Winter Is  Coming";
// Add your code below this line
function urlSlug(title) {
  let url = title.trim().toLowerCase().split(/\s+/).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/74.0.3729.169 Safari/537.36.

Link to the challenge:

It’s because you literally changed globalTitle’s value.

If you reset your code, it won’t complain anymore. Here is what it looks like by default.

var globalTitle = “Winter Is Coming”;

Damn! You are right lol, I forgot about that detail. Thanks a lot man! Code approved :slight_smile: