Skip to content

Converts a string into a slugified string in TypeScript

const slugify = (str: string): string => str.toLowerCase().replace(/\s+/g, '-').replace(/[^\w-]+/g, '');

slugify('Hello World'); // -> hello-world


See also  K Closest Points to Origin - Leetcode Challenge - Python Solution

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.