Convert Strings to URL Slugs, why is my code not accepted?

Tell us what’s happening:
Wondering why my solution is not working. console.log(" Winter Is Coming"); returns the required “winter-is-coming” but task does not accept my code. I must be missing something trivial…

Your code so far

// Only change code below this line
function urlSlug(title) {
var array = title
var string = array
return string;

// Only change code above this line

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.83 Safari/537.36.

Challenge: Apply Functional Programming to Convert Strings to URL Slugs

Link to the challenge:

you can check with adding

console.log(urlSlug(" Winter Is  Coming"))

at the bottom of the editor. The output is winter-is--coming when it should be winter-is-coming

add console.log(array) inside the function to see your issue

1 Like

Thank you for your reply! I did not notice that there was more than just the white space at the start of the sentence. This clears it up!