Created
August 28, 2013 21:59
-
-
Save mbjordan/6371860 to your computer and use it in GitHub Desktop.
Create a URL-friendly string on multiple string, as a list. Returns an Array.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Return; | |
function slugify(){ | |
var O = Array.prototype.slice.call(arguments), | |
t = [], | |
x = 0, | |
i; | |
for (i in O){ | |
if (O.hasOwnProperty(i) && typeof O[i] === "string"){ | |
t[x] = O[i].toLowerCase().replace(/[^\w ]+/g,'').replace(/ +/g,'-'); | |
x++; | |
} | |
} | |
return t; | |
} | |
Return = slugify("Yo, mang!", "1234"); | |
console.log(Return, Return[0], Return[1]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment