Common text transformations:
// Title case
function toTitleCase(str) {
return str.split(" ")
.map(word => word[0].toUpperCase() + word.slice(1).toLowerCase())
.join(" ")
}
console.log(toTitleCase("hello world")) // "Hello World"
// Slug from title
function toSlug(title) {
return title.toLowerCase()
.trim()
.replaceAll(" ", "-")
}
console.log(toSlug("My Blog Post")) // "my-blog-post"