By utilizing these methods, you can manipulate and transform strings to fit your specific programming needs. Whether you’re working on a small script or a large-scale project, understanding the various methods available to you can help streamline your code and make it more efficient.
It is important to note that if the index value provided is out of range. Then the charAt method will return an empty string. Additionally, if no index value is provided, the method will automatically use the default index value of 0. By understanding these nuances of the charAt method, we can effectively leverage it to achieve our desired String manipulations.
const str = 'developerhelps'; const str2 = str.charAt(0); console.log(str2);
const str = 'developerhelps'; const str2 = str.toUpperCase(); console.log(str2);
const str = 'developerhelps'; const str2 = str.slice(1); console.log(str2);
Now Let us combine all these function to capitalize the first word of the input String
const str = 'developerhelps'; const str2 = str.charAt(0).toUpperCase() + str.slice(1); console.log(str2);
After this we capitalize the first letter of a word but we have to captialize the first letter of each word in a given string. This can be achieved via –
Follow for More Info – https://instagram.com/developerhelps?igshid=MzRlODBiNWFlZA==