It seems like my solution is working fine on console. But I am not passing one of the test cases. This could be a bug, but I think it could also be something I messed up. Can someone help please? Thanks.
Your code so far
// the global variable
var globalTitle = "Winter Is Coming";
// Add your code below this line
function urlSlug(title) {
return title.trim().toLowerCase().split(" ").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/65.0.3325.181 Safari/537.36.
this is working for me in a console, passing "Winter Is Coming" and " Winter Is Coming"
but failing "A Mind Needs Books Like A Sword Needs A Whetstone" and "Hold The Door"
function urlSlug(title) {
return [].concat(globalTitle.split(/\W/)).map(item=>item.toLowerCase()).join('-');
}
I’ve edited your posts for readability. When you enter a code block into the forum, precede it with a line of three backticks and follow it with a line of three backticks to make easier to read. See this post to find the backtick on your keyboard. The “preformatted text” tool in the editor (</>) will also add backticks around text.
// running test
Your code should not use the replace method for this challenge.
urlSlug(" Winter Is Coming") should return "winter-is-coming".
// tests completed
I don’t know why $nbsp; is sending a parameter for test and how to remove this space because my solution is
// the global variable
var globalTitle = "Winter Is Coming";
// Add your code below this line
function urlSlug(title) {
//.replace(/ /g, ' ')
return title.toLowerCase().split(" ").join("-");
}
// Add your code above this line
var winterComing = urlSlug(globalTitle); // Should be "winter-is-coming"
can anyone tell what’s wrong in my code. it shows correct result in the console but it is not passing the test. Please help
// the global variable
var globalTitle = " Winter Is Coming";
// Add your code below this line
function urlSlug(title) {
return title.toLowerCase().split(/[^a-zA-Z0-9]/).filter((x)=>x!="").join("-");
}
// Add your code above this line
var winterComing = urlSlug(globalTitle);
console.log(winterComing); // "winter-is-coming"