Capitalize first letter of each word in JS

前端 未结 17 719
闹比i
闹比i 2021-01-03 23:26

I\'m learning how to capitalize the first letter of each word in a string and for this solution I understand everything except the word.substr(1) portion. I see that it\'s a

17条回答
  •  粉色の甜心
    2021-01-03 23:47

    Here is a quick code snippet. This code snippet will allow you to capitalize the first letter of a string using JavaScript.

    function CapitlizeString(word) 
    {
        return word.charAt(0).toUpperCase() + word.slice(1);
    }
    

提交回复
热议问题