Function to convert a string to camel case

    /**
     * This function is used to convert a string to camel case.
     * @param {string} str - The string to be converted to camel case.
     * @returns {string} The camel case version of the input string.
     */
    const toCamelCase = (str) => {
        return str.toLowerCase().replace(/bw/g, function (char) {
            return char.toUpperCase();
        });
    }

Example:

  • Input: hello world , output: Hello World
  • Input HELLO WORLD, output: HELLO WORLD

Leave a comment

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