Learn to Capitalize the First Letter of Each Word with Go
dev.to·16h·
Discuss: DEV
Flag this post

Hey, there! Golang enthusiastics. I hope you are putting effort in the Golang journey. This week we are improving the learning by using Go’s internal packages. We are using string package.

Problem Statement

Write a function that takes a string as input and returns the string with the first letter of each word capitalized. The words are separated by spaces.

Breaking down the problem statement: we have an input—a string of words separated by spaces. We need to process each word to capitalize its first letter. Finally, our output will be the same string, but processed.

Now it’s time to define our algorithm to process the string and obtain the requested output.

Algorithm to Solve it

First, we need to split the whole string into words. Thi…

Similar Posts

Loading similar posts...