I can not understand how to clear the whitespace in string

Why this code can’t clear the whitespace on the left of the string. The challenge needs the string without any whitespace.

but I use trim() method.

// Only change code below this line
function urlSlug(title) {
return title.toLowerCase().trim().split(" ").join("-");
// Only change code above this line
console.log(urlSlug(" Winter Is Coming"));

//urlSlug(" Winter Is  Coming") should return the string 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/89.0.4389.114 Safari/537.36.

Challenge: Apply Functional Programming to Convert Strings to URL Slugs

Link to the challenge:

urlSlug(" Winter Is  Coming") should return the string winter-is-coming.

you are returning


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