programming-examples/js/String/Uncapitalize each word in the string.js

5 lines
185 B
JavaScript
Raw Normal View History

2019-11-15 12:59:38 +01:00
function unCapitalizeWords(str)
{
return str.replace(/\w\S*/g, function(txt){return txt.substr(0).toLowerCase();});
}
console.log(unCapitalizeWords('JS STRING EXERCISES'));