I'm trying to capitalize first letter of array with strings, I add my method to String
but it's only returning the first letter capitalized not the full sentence. So it should be "Hi There How Are You?"
const str = "Hi there how are you?";
String.prototype.toJadenCase = function(st) {
let arr = st.split(" ");
arr.forEach(function(ele, index) {
arr[index] = ele.charAt(0).toUpperCase();
});
return arr;
};
console.log(String.prototype.toJadenCase("Hi there how are you"));
Returns array of only first letter not full word ["H", "T", "H", "A", "Y"]