Tell us what’s happening:
I was writing this challenge and trying my code, but even though I was certain it was it didn’t pass the first test.
Then I tried googling solutions and none passed the test for some reason.
Apparently, the problem is some bug and just resetting the code fixes the problem.
This link helped me.
Please put some notice until you fix the bug.
Your code so far
// the global variable
var globalTitle = "Winter Is Coming";
// Add your code below this line
function urlSlug(title) {
let slug = title.toLowerCase().split(/\s/).filter(function(i) {
return i !== "";
}).join("-");
console.log(globalTitle);
return slug;
}
// 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/67.0.3396.99 Safari/537.36.
I did it like this, i could not find a way to remove that first whitespace character in second test " Winter is…" so i used .trim()
Does anybody know how to remove that whitespace before 1st word? thanks
solution:
function urlSlug(title) {
return title.toLowerCase().trim().split(/\s+/g).join("-");
}
var winterComing = urlSlug(globalTitle); // Should be "winter-is-coming"