How do I calculate the sum of all the numbers in a string by using the JavaScript ? In the example below, the expected result would be 2+0+1+5. My attempt is below.
var a = "weare20boysand15girls";
var i;
for(i=0; i<a.length; i++){
var b = Number(a[i]);
var c=0;
c += b;
console.log(c);