JSFiddle - React, Tailwind, and code Playground
JavaScript
$scope = function() {};
$scope.data = {};
$scope.data.artists = ["Aa", "Bb"];
$scope.sortedNames = {
A : [],
B : []
};
function foo() {
//loop to go through my artists array
for (var i = 0; i < $scope.data.artists.length; i++) {
//loop to go through my sortedNames array
$scope.sortedNames[$scope.data.artists[i].charAt(0)].push($scope.data.artists[i]);
}
}
foo();
console.log($scope.sortedNames);