As the title says I am trying to return the total number of upper case characters in a function that accepts an array of strings.
Here is what I have so far:
function totalCaps(str) {
var count=0,len=str.length;
for(var i=0;i<len;i++) {
if(/[A-Z]/.test(str.charAt(i))) count++;
}
return count;
}
console.log(
totalCaps(["AwesomE", "ThIngs", "hAppEning", "HerE"])
);
Am I going about this the best way? I'm sure there is an alternative solution as to compared what I am doing.
I am trying to return: 8 for the given array of strings that I introduced at the bottom.