JSFiddle - React, Tailwind, and code Playground

JavaScript

var value = 'i Walk my  DOG to the Park';

var camelCase = value.split(' ').map(function(word, i) {
    return (word[0] || '')[i == 0 ? 'toLowerCase' : 'toUpperCase']() +
           word.substr(1).toLowerCase();
}).join('');

document.body.innerHTML += value + ' --> ' + camelCase;