Apply Functional Programming to Convert Strings to URL Slugs- help

Apply Functional Programming to Convert Strings to URL Slugs- help
0

#1

Please help. I don’t know what I need to do to pass this challenge. I’m failing this test.

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

And here is my code.

// the global variable
var globalTitle = "Winter Is Coming";

// Add your code below this line
function urlSlug(title) {
 let hyphenStr = title.toLowerCase().split(" ").join("-");
  return hyphenStr;
}
// Add your code above this line

var winterComing = urlSlug(globalTitle); // Should be "winter-is-coming"
console.log(winterComing);

Apply Functional Programming to Convert Strings to URL Slugs


#2

If you have not already checked, put the following console.log statements at the bottom and view your browser’s console to see what your function is actually returning.

console.log('failing test is below');
console.log('function returns');
console.log(urlSlug(" Winter Is   Coming")); // should return "winter-is-coming".
console.log('failing test above');

#3

Ok thanks I see it creates more hyphens because of the extra white space so I need to remove that.


#4

What I did above is a great way to test out any code and see the results.