working with this function call:

```
var StringData = window.ToCamelCase({ 'string': 'HELLO WORLD', 'remSpace': false });
console.log(StringData);

```

and this is my script function:

```
function ToCamelCase(data) {
    data['string'] = data['string'].replace(/(?:^\w|[A-Z]|\b\w)/g, function(word, index) {
        return index == 0 ? word.toUpperCase() : word.toLowerCase();
    });
    if (data['remSpace']) {
        data['string'] = data['string'].replace(/\s/g, '');
    }
    return data['string'];
}

```

i dont get error; but not work properly, if i passed and string like this:

```
"HELLO WORLD"

```

this moment second word not put first letter uppercase

the output is: `"Hello world"` and i expect: `"Hello World"`

***First letter per word Upper Case and the following Lower Case is the rule.***

**what am I doing wrong?**