My code looks correct but I keep failing the third condition

Tell us what’s happening:
Describe your issue in detail here.
My Code looks correct but I keep failing the third condition which is " Winter is coming". I use the combined methods of trimStart, split and join. When I console log the function I get the correct result. Can anyone please tell me where I am doing wrong and how to pass this lesson.
Your code so far

// Only change code below this line
function urlSlug(title) {
return title.trimStart().toLowerCase().split(" ").join("-");

// Only change code above this line

console.log(urlSlug(" 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/90.0.4430.93 Safari/537.36.

Challenge: Apply Functional Programming to Convert Strings to URL Slugs

Link to the challenge:

the third condition has

" Winter Is  Coming"

(two spaces)
and the current output is winter-is--coming

Also, you have not considered what to do if there are extra spaces at the end, even if there is not a test for that

Thanks for the quick reply. I think I only apply the trimStart. I should have apply it on both sides as trim(). At last the following code solves my problem and let me pass the test.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.