Skip to content

Converts a string into a slugified string in TypeScript

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

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

Source

See also  Fizz Buzz - Leetcode Challenge - C++ 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.