A slug is the URL-safe version of a title — lowercase, hyphen-separated, and reduced to just letters, digits, and single hyphens (the my-post-title you see in a blog URL or a docs anchor). Write slugify(str) that turns any string into one: "Hello, World!" becomes "hello-world" and "Café Crème" becomes "cafe-creme". The work is in the messy inputs — accented letters, punctuation, and stray or repeated spaces — each of which needs its own cleanup step.
slugify(str)
// str: any string — a title, heading, or filename
// returns: a slug containing only [a-z0-9-], with no
// leading, trailing, or doubled hyphens
slugify('Hello, World!'); // 'hello-world'
slugify(' Multiple Spaces '); // 'multiple-spaces'
slugify('Node.js & React'); // 'node-js-react'
slugify('Top 10 Tips'); // 'top-10-tips'
slugify('Café Crème'); // 'cafe-creme' (accents stripped)
slugify('Crème Brûlée'); // 'creme-brulee'
slugify('!!! ??? ...'); // '' (all symbols → empty)
slugify(''); // ''
a–z, 0–9, and -. No uppercase, no spaces, no punctuation.é becomes e and ü becomes u, so "Zürich" slugs to "zurich". That means normalizing Unicode, not a hand-written lookup table."a & b" is "a-b", never "a---b"."--Hello--" is "hello"."Top 10" keeps its 10."".