I have an angular app in this plunker

I have a text area which has some text in the format of (key,count) in them by default.

What i am trying to achieve is this(in the calc() function):

When the button is pressed the results of the summation should be displayed.

I was able to split the data from the textarea into different arrays but i am missing the logic to add when the names match.

EDIT: please notice a few updates in my plunker

New to angular and javascript!

Here's another way to do it. I can't speak to performance against PSL's method, but I think this reads a little easier to my not-very good at javascript eyes.

<!-- language: lang-js -->
function groupByName(names) {
  inputArray = names.split('\n');
  outputArray = {};
  
  for (i = 0; i < inputArray.length; i++) {
      
      var keyValuePair = inputArray[i].split(',');
      var key = keyValuePair[0];
      var count = Number(keyValuePair[1]);
      
      // create element if it doesnt' exist
      if (!outputArray[key]) outputArray[key] = 0;
      
      // increment by value
      outputArray[key] += count;
  }

  return outputArray;
}

This will produce an object that looks like this:

<!-- language: lang-js -->
{
  "John": 6,
  "Jane": 8
}

You can display the name of each property and it's value with ng-repeat:

<!-- language: lang-html -->
<li ng-repeat="(key, value) in groupedNames">
  The total for {{key}} is {{value}}
</li>

It's not an overwhelmingly complex bit of javascript, depending on the number of name value pairs. So you can probably even get rid of the manual calc button and just put a $watch on values in order to automatically recalculate totals with every change.

<!-- language: lang-js -->
$scope.$watch('values', function() {
  $scope.groupedNames = groupByName($scope.values);
});

Demo in Plunker