
									 Problem
								
								
									 Solution
								
								
									 Submissions
								
								
							Capitalize First Letter of Each Word
								Certification: Basic Level
								Accuracy: 0%
								Submissions: 0
								Points: 5
							
							Write a JavaScript function to capitalize the first letter of each word in a given string. The function should convert the first character of every word to uppercase while keeping the rest of the characters in their original case.
Example 1
- Input: str = "hello world programming"
 - Output: "Hello World Programming"
 - Explanation: 
- The input string contains three words: "hello", "world", "programming". 
 - First letter of "hello" becomes "H", making it "Hello". 
 - First letter of "world" becomes "W", making it "World". 
 - First letter of "programming" becomes "P", making it "Programming". 
 - The final result is "Hello World Programming".
 
 - The input string contains three words: "hello", "world", "programming". 
 
Example 2
- Input: str = "javascript is awesome"
 - Output: "Javascript Is Awesome"
 - Explanation: 
- The input string contains three words: "javascript", "is", "awesome". 
 - First letter of "javascript" becomes "J", making it "Javascript". 
 - First letter of "is" becomes "I", making it "Is". 
 - First letter of "awesome" becomes "A", making it "Awesome". 
 - The final result is "Javascript Is Awesome".
 
 - The input string contains three words: "javascript", "is", "awesome". 
 
Constraints
- 1 ≤ str.length ≤ 1000
 - The string may contain multiple spaces between words
 - Words are separated by spaces
 - Time Complexity: O(n) where n is the length of string
 - Space Complexity: O(n) for the result string
 
Editorial
									
												
My Submissions
										All Solutions
									| Lang | Status | Date | Code | 
|---|---|---|---|
| You do not have any submissions for this problem. | |||
| User | Lang | Status | Date | Code | 
|---|---|---|---|---|
| No submissions found. | ||||
Solution Hints
- Split the string into individual words using space as delimiter
 - Iterate through each word in the array
 - For each word, capitalize the first character using toUpperCase()
 - Keep the rest of the characters as they are using substring()
 - Join all the processed words back with spaces
 - Handle edge cases like empty strings or single characters