EXERCISE · AlgoCasts

Capitalize

Write a function that accepts a string. The function should capitalize the first letter of each word in the string then return the capitalized string.

3 testsAlgoCastsGPL-3.01 alternateexercise 08 of 26

Directions

Directions

Write a function that accepts a string. The function should capitalize the first letter of each word in the string then return the capitalized string.

Examples#

JS
capitalize('a short sentence') --> 'A Short Sentence'capitalize('a lazy fox') --> 'A Lazy Fox'capitalize('look, it is working!') --> 'Look, It Is Working!'

Try it first#

Copy the stub, make the 3 tests pass on your machine, then open the solution. The reveal is remembered per page in this browser.

JSexercises/capitalize/index.js
function capitalize(str) {} module.exports = capitalize;

See also