repl.it
@anonymous/

IllinformedLonelyTilefish

JavaScript

No description

fork
loading
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// This part is working, now I need to loop it
function titleCase(str) {
        var words = str.replace(myRegExp, "").toLowerCase().split(" ");
	    var myRegExp = /[^a-zA-Z][\.,-\/#!$%\^&\*;:{}=\-_`~()]?/ig;

	    console.log (words + ' <= word list');

    for (i = 0; i <= words.length; i++){

        
        var current = words[i].slice(0,1).toUpperCase() + words[i].slice(1).toLowerCase();
        console.log(current + ' <= current word');
        var titled = [];
        titled.push(current);
        console.log(titled  + ' <= titled word list');
    }
    return titled;
};

titleCase('help I need somebody');
Native Browser JavaScript