Q:

How to store values from one list to the other list at specific attribute?

I have two lists. I want to store the data from both lists to a single list in angularjs.
I have tried using for loop for assigning values but it does not seem to be working.
$scope.CustomerSize_Value = [];
$scope.CustSizeAttrib_Id = [];

$scope.StoreAttributeList = {
  'customerSizeAttribute_Id': 0,
  'customerSize_Value': "",
};

Here i want to store the values from CustSizeAttrib_Id to the StoreAttributeList.customerSizeAttribute_Id and values from CustomerSize_Value to the StoreAttributeList.customerSize_Value.
I want the StoreAttributeList to be like: 
[
  {customerSizeAttribute_Id:1, customerSize_Value:"Hello"},
  {customerSizeAttribute_Id:3, customerSize_Value:"Info"},
  {customerSizeAttribute_Id:65, customerSize_Value:"Foo"}
]

Thanks in advance.

A:

This sounds like essentially a double for loop problem.  Assuming there are no gaps in your arrays and they are the same length, you can do something like this with reduce and you should get the object array that you're looking for.
const size = [1,2,3];
const attr = ['a', 'b', 'c'];

const reduced = (_size, _attr) => {

    return _size.reduce((prev, next, index) => {
        prev.push({
            s: next, a: _attr[index]
        });
        return prev;
    }, []);

}

console.log(reduced(size, attr));

// [{s: 1, a: "a"}, {s: 2, a: "b"}, {s: 3, a: "c"}] 

