EasyStringsNot started

Headline to URL slug

A small publishing tool needs a URL slug. Read a headline made of letters and single spaces, convert it to lowercase, and replace every space with a hyphen.

Input

One line containing 1 to 10 words separated by single spaces.

Output

One lowercase line with words joined by hyphens.

Example 1

Input

Warehouse Stock Report

Output

warehouse-stock-report

Letters are lowercased and the two spaces become hyphens.

Constraints

  • The headline contains only ASCII letters and single spaces
  • No leading or trailing spaces

Hints

Hint 1 of 3

toLowerCase changes the letter case.

Hint 2 of 3

split(' ') creates one array element per word.

Hint 3 of 3

join('-') reconnects those words with hyphens.

Solution

Show a reference solution and explanation
 JavaScript · reference solution
const headline = readline();
console.log(headline.toLowerCase().split(' ').join('-'));

Why it works

The transformation is a pipeline: normalise letter case, split at the known delimiter, then join with the new delimiter. The restricted input means punctuation cleanup is intentionally unnecessary here.

Lesson for this exercise: JavaScript Strings: Methods, Template Literals and Slicing

Your program
const headline = readline();
// create and print the slug

Tests: 3 cases including the examples. Passing every test marks the exercise solved in this browser.

Ready for a challenge?

How this page was checked. Every program on it was run with Node.js 22 at build time; runs in your browser in an isolated Web Worker by the publishing checks, and the output shown is what it printed. The Run buttons execute the same code on your device; nothing you type is sent anywhere.