Lodash title case (uppercase first letter of every word)

前端 未结 13 1661
萌比男神i
萌比男神i 2021-01-30 19:25

I\'m looking through the lodash docs and other Stack Overflow questions - while there are several native JavaScript ways of accomplishing this task, is there a way I can convert

13条回答
  •  醉梦人生
    2021-01-30 19:42

    Here's a way using ONLY lodash methods and no builtin methods:

    _.reduce(_.map(_.split("Hello everyOne IN the WOrld", " "), _.capitalize), (a, b) => a + " " + b)
    

提交回复
热议问题