Strings
URL Slugs
URL Slugs
A slug is a readable piece of a URL. It usually has lowercase words separated by hyphens.
Your task: Write createSlug. It should trim the title, convert it to lowercase, and replace spaces with hyphens.
Free with a JS Exercises account
Sign in to start coding, run your solution, and keep your progress saved for later. No payment needed.
By continuing, you agree to our Terms and Privacy Policy. We'll send occasional product updates and news. You can unsubscribe anytime.
URL Slugs
A slug is a readable piece of a URL. It usually has lowercase words separated by hyphens.
Your task: Write createSlug. It should trim the title, convert it to lowercase, and replace spaces with hyphens.