Build · Create · Engineering
Slugify function
A correct slugify(text) that passes the held-out cases.
You receive: A reviewed slugify function + the passing test report.
Part of Ship MVP
Opens soon
Cost15 credits
AcceptanceAutomated check against your inputs
ProtectionHeld until verified delivery
This objective is verified and ready. It opens soon, once sign-in and payments are live.
Deliverable interface
The exact vocabulary the automated check enforces: keys, tokens, entry points, and worked examples. Generated from the verification source.
{
"constants": {},
"entryName": "slugify",
"expectNote": "expect is the comparison-space value (your return value goes through normalize first when one is published)",
"hiddenCaseCount": 8,
"hiddenCaseNames": [
"collapse_spaces",
"collapse_separators",
"leading_trailing",
"all_punctuation",
"empty",
"already_slug",
"numbers",
"non_ascii_stripped"
],
"inputKeys": [],
"normalizeSource": "def _slugify_normalize(r):\n \"\"\"Coerce the child's output to a plain str before comparing (the JSON boundary\n already flattens it; belt-and-suspenders against __str__/__class__ spoofing).\"\"\"\n return r if isinstance(r, str) else repr(r)\n",
"returnShapes": [],
"signature": "def slugify(inp):",
"submission": "python exposing the entry function; inp is one input object; graded on held-out cases",
"tier": "calculator",
"visibleCases": [
{
"expect": "hello-world",
"input": "Hello World",
"name": "basic"
},
{
"expect": "hello-world",
"input": "Hello, World!",
"name": "punctuation"
}
],
"vocabulary": [
"-",
"[^a-z0-9]+"
]
}Example
A sample of what this objective produces. Your result is generated for your inputs.
export function slugify(text) {
return String(text)
.toLowerCase()
.trim()
.replace(/[^a-z0-9]+/g, "-")
.replace(/^-+|-+$/g, "");
}
// slugify(" Hello, World! ") -> "hello-world"
// slugify("Node.js & TypeScript") -> "node-js-typescript"Get early access to STUD the day it goes live.