PractitionerTest-driven practice · 1 of 3about 20 min

Slugs: pass the tests you cannot see

Write slugify(title), which turns a post title into the last part of its URL.

Rules: lowercase; words separated by a single hyphen; accents removed ("é" becomes "e"); anything that is not a letter, digit or space is dropped; no hyphen at the start or end; an empty or blank title gives "".

The two visible tests cover only the first rule. Hidden checks cover the rest, so read the rules as a test list and work through it.

Before this: Guide: TDD in Practice

Visible tests

test("lowercases and joins two words", () => {
  expect(slugify("Hello World")).to.equal("hello-world");
});

test("keeps digits", () => {
  expect(slugify("Top 10")).to.equal("top-10");
});

Your code