Skip to content
This repository has been archived by the owner on Aug 28, 2019. It is now read-only.

Commit

Permalink
Apply Functional Programming to Convert Strings to URL Slugs solution…
Browse files Browse the repository at this point in the history
….md (#8250)

* Update index.md

search for non-word character, split at these points, then using the filter method, filter for extra space, join the dash, and then convert to lower case.

* Update index.md
  • Loading branch information
neydoo authored and amandeepmittal committed Jul 11, 2018
1 parent 9e087e6 commit a7bc78b
Showing 1 changed file with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,16 @@ title: Apply Functional Programming to Convert Strings to URL Slugs
---
## Apply Functional Programming to Convert Strings to URL Slugs

This is a stub. <a href='https://github.com/freecodecamp/guides/tree/master/src/pages/certifications/javascript-algorithms-and-data-structures/functional-programming/apply-functional-programming-to-convert-strings-to-url-slugs/index.md' target='_blank' rel='nofollow'>Help our community expand it</a>.
// the global variable
var globalTitle = "Winter Is Coming";

<a href='https://github.com/freecodecamp/guides/blob/master/README.md' target='_blank' rel='nofollow'>This quick style guide will help ensure your pull request gets accepted</a>.
// Add your code below this line
function urlSlug(title) {
return title.split(/\W/).filter((obj)=>{
return obj !=='';
}).join('-').toLowerCase();

}
// Add your code above this line

<!-- The article goes here, in GitHub-flavored Markdown. Feel free to add YouTube videos, images, and CodePen/JSBin embeds -->
var winterComing = urlSlug(globalTitle); // Should be "winter-is-coming"

0 comments on commit a7bc78b

Please sign in to comment.