My solution has an error: Apply Functional Programming to Convert Strings to URL Slugs

My solution for this problem has an error, when I run the code the output show me this error:

The globalTitle variable should not change.

The globalTitle is ok, no mutable, but I code don’t pass, this is my solution.

function urlSlug(title) {
    return title.toLowerCase().match(/\w+/g).join("-");
}

Can you post all the code in the editor. The first two lines should look like below:

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

sorry, I did two solution, but I like the short.

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

// Add your code below this line
function urlSlug(title) {
    return title.toLowerCase().match(/\w+/g).join("-");
}
// Add your code above this line

var winterComing = urlSlug(globalTitle); // Should be "winter-is-coming"

console.log(winterComing);

You can not change the global variable globalTitle. Reset the code to see what it should be.

2 Likes

you changed this, you can reset your code or copy how it should be from @RandellDawson post above

Thank you, problem solved!