js-01-slugify
1.000
Proposed solution
```js
export function slugify(input) {
return input
.toLowerCase()
.replace(/[^a-z0-9]+/g, '-')
.replace(/^-|-$/g, '');
}
```Test output (stdout)
TAP version 13 # Subtest: spaces become single hyphens ok 1 - spaces become single hyphens --- duration_ms: 0.425334 type: 'test' ... # Subtest: punctuation collapses and ends are trimmed ok 2 - punctuation collapses and ends are trimmed --- duration_ms: 0.064721 type: 'test' ... # Subtest: already-clean input is unchanged ok 3 - already-clean input is unchanged --- duration_ms: 0.046311 type: 'test' ... # Subtest: digits are preserved ok 4 - digits are preserved --- duration_ms: 0.04587 type: 'test' ... # Subtest: runs of mixed separators collapse to one hyphen ok 5 - runs of mixed separators collapse to one hyphen --- duration_ms: 0.07582 type: 'test' ... # Subtest: leading and trailing junk is trimmed ok 6 - leading and trailing junk is trimmed --- duration_ms: 0.04273 type: 'test' ... # Subtest: all-separator input becomes empty string ok 7 - all-separator input becomes empty string --- duration_ms: 0.040741 type: 'test' ... # Subtest: empty string stays empty ok 8 - empty string stays empty --- duration_ms: 0.03997 type: 'test' ... # Subtest: non-ASCII letters act as separators ok 9 - non-ASCII letters act as separators --- duration_ms: 0.053161 type: 'test' ... 1..9 # tests 9 # suites 0 # pass 9 # fail 0 # cancelled 0 # skipped 0 # todo 0 # duration_ms 31.18164
System prompt
You are an expert programmer. Solve the task exactly as specified. Output your solution as fenced code blocks using the required file name(s) and the exact function/type signatures requested. Prefer correctness; do not include prose outside code unless asked.