Answers for "2. Write a html JavaScript function that accepts a string as a parameter and converts the first letter of each word of the string in upper case."

7

capitalize first letter javascript

function capitalizeFirstLetter(string) {
  return string.charAt(0).toUpperCase() + string.slice(1);
}

console.log(capitalizeFirstLetter('foo bar bag')); // Foo
Posted by: Guest on June-22-2020
3

javascript uppercase first character of each word

const uppercaseWords = str => str.replace(/^(.)|\s+(.)/g, c => c.toUpperCase());

// Example
uppercaseWords('hello world');      // 'Hello World'
Posted by: Guest on July-03-2020

Code answers related to "2. Write a html JavaScript function that accepts a string as a parameter and converts the first letter of each word of the string in upper case."

Code answers related to "Javascript"

Browse Popular Code Answers by Language