Himas Rafeek
Posted on: 3 years ago

Javascript capitalize string function

This snippet capitalizes the first letter of a string.


                                          const capitalize = ([first, ...rest]) =>
  first.toUpperCase() + rest.join('');
  
capitalize('fooBar'); // 'FooBar'
capitalize('fooBar', true); // 'FooBar'