title: Javascript return filtered array inside switch statement
body: <p>What is correct way of doing filter on array inside switch statement</p>
  
  <pre><code>let filteredMachines = (filterTerm,filterField) =&gt; {
         switch (filterField) {
         case 'NomAppareil':this.props.machines.filter(machine =&gt; {
             return machine.nomAppareil === filterTerm;
         });
         break;
  
         case 'CodeAppareil':this.props.machines.filter(machine =&gt; {
             return machine.codeAppareil === filterTerm;
         });
         break;
  
         case 'NomClient':this.props.machines.filter(machine =&gt; {
             return machine.nomClient === filterTerm;
         });
         break;
  
         case 'CodeClient':this.props.machines.filter(machine =&gt; {
              console.log('inside CodeClient ='+JSON.stringify(machine));
             return (machine.codeClient == filterTerm);
         });
         break;
  
         case 'NoSerie':this.props.machines.filter(machine =&gt; {
             return machine.noSerie === filterTerm;
         });
         break;
  
         default: return this.props.machines;
       }
     };
  </code></pre>
  
  <p>Edit: I found working solution given below</p>
  
  <pre><code>let filteredMachines = machines.filter((machine) =&gt;{
       switch (filterField) {
       case 'NomAppareil':  return machine.nomAppareil === filterTerm;
       case 'CodeAppareil': return machine.codeAppareil === filterTerm;
       case 'NomClient': return machine.nomClient === filterTerm;
       case 'CodeClient': return machine.codeClient === filterTerm;
       case 'NoSerie': return machine.noSerie === filterTerm;
             default: return true;
     }
  </code></pre>
  
  <p>});</p>