This will take your JavaScript string and make it lowercase, and convert any spaces to dashes (-).
This is a decent way to “slugify” a string, or make a URL-friendly slug of a string, only if you’re sure that the string will not contain any other special characters such as commas, periods, etc. This will not remove commas or periods from the string.
var string = 'THIS IS SOME STRING'; var slug = string.replace(/\s+/g, '-').toLowerCase();
Questions and Comments are Welcome