title: Trying to return new arrays based on initial array
body: <p>I have an array of vehicles that are available to buy on a company website. Within the van array there is a nested array that contains the model and the vehicle value.</p>
  
  <pre><code>{vanNumber: "7654628", vanDescription: "VW Campervan", value: {make: "VW", amount: 11660}}
  {vanNumber: "9873093", vanDescription: "Renault Campervan", value: {make: "Renault", amount: 3429}}
  {vanNumber: "1739566", vanDescription: "Nissan Campervan", value: {make: "Nissan", amount: 5600}}
  {vanNumber: "3949219", vanDescription: "VW", value: {make: "VW", amount: 1960}}
  </code></pre>
  
  <p>I'm trying to return an array for each car brand and the total value of each individual brand. I already have the addition part working but I'm trying to loop through the array and return a new array for each car manufacturer. </p>
  
  <p>So in this example, I would like to return a VW array that contains the two VW vehicles based on the value.make value and two other arrays, one for the Nissan and one for the Renault.</p>
  
  <p>I was <strong>previously returning the array like this</strong> (see below)</p>
  
  <pre><code>// returns an array of VW vehicles when make = VW
   if (vanMake != undefined) {
          let result = vanMake.filter((x) =&gt; {
              return x.value.make === 'VW';
          });
  
          return result
     }
  </code></pre>
  
  <p>But if I added 3000 cars to the array, <strong>I'd like to return a new array to the view for each manufacturer and the total value of each car under that make without having to do an if else for every car brand</strong>. </p>
  
  <pre><code>export function toTotalVanValue(state: fromVans.State): any {
  
  let vanMake = state.vans.vanDetails.vehicle;
  
          //prints out the array of objects 
          console.log('vanMake', vanMake);
  
          if (vanMake != undefined) {
              let result = vanMake.filter((x) =&gt; {
                  let make = x.value.make;
                  if (make) {
                      console.log ('make', make);
                      return make
                  }
                  return x.value.make;
              });
              result.forEach(function(element) {
                  vanMake.filter((x) =&gt; {
                      console.log('x.value.make', x.value.make);
                      return x.value.make;
                  });
  
                //prints out each element individually
                  console.log('element element', element);
                });
  
          //prints out the array of objects 
              console.log('result', result);
              return result
          }
      }
  </code></pre>