DEV Community

打coding的奥特曼
打coding的奥特曼

Posted on

一行代码把句子里的每个单词首字母大写

str = 'hello world, today is saturday'
str.split(' ').map( i =>  i[0].toUpperCase()+i.slice(1)   
    ).join(' ')
Enter fullscreen mode Exit fullscreen mode

Top comments (0)