Function to capitalize the first letters of a word

 function capitalizeFirstLetters(str) {
            // Split the input string into an array of words
            const words = str.toLowerCase().split(' ');

            // Capitalize the first letter of each word
            for (let i = 0; i < words.length; i++) {
                words[i] = words[i].charAt(0).toUpperCase() + words[i].slice(1);
            }

            // Join the words back into a single string
            const result = words.join(' ');

            return result;
        }

 let customerName = capitalizeFirstLetters(custName)

Leave a comment

Your email address will not be published. Required fields are marked *