Medium javascript

Title case a sentence

Problem

Convert "hello world from node" to title case.

Hints
  • split by space, capitalize first char of each word

Your practice code

Ready — edit the code above and click Run.

Solution

const s = "hello world from node";
console.log(s.split(" ").map(w => w[0].toUpperCase() + w.slice(1)).join(" "));

Try solving on your own first, then reveal the official answer.

Explanation

Map over words—similar pattern to React list rendering.

Toolliyo Assistant
Ask about tutorials, ebooks, training, pricing, mentor services, and support. I use public site content only—not admin or internal tools.

care@toolliyo.com

Need callback? Share your details