I don’t get what’s wrong in my answer. Its working fine thou for the mentioned params. Your code so far
function urlSlug(title) {
const result = title.trim().split(/\W/).join('-').toLowerCase();
return result;
}
// Only change code above this line
console.log(urlSlug(" Winter is Coming "))
Thanks a load, Kevin. I really appreciate you taking your time and explaining this out. I really must admit developer’s community is the best out there.
I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.
You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.