Skip to content

Instantly share code, notes, and snippets.

@mbjordan
Created August 28, 2013 21:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mbjordan/6371860 to your computer and use it in GitHub Desktop.
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.
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