title: JS category conversion function
body: <p><strong>Group to Category Conversion</strong></p>
  
  <hr>
  
  <pre><code>var Auto = ['new_auto', 'add_auto'];
  //more category objects 
  
  var categories = [Auto, Fire, Health, Life, Bank];
  
  function groupToCat(group) {
  
      for (x = 1; x &lt; categories.length; x++) {
          for (i = 1; i &lt; categories[x].length) {
              if (group == categories[x][i]) {
                  return categories[x]
              }
          }
      }
  }
  </code></pre>
  
  <hr>
  
  <p>I'm trying to use a loop within a loop in combination with a multi-dimensional array to achieve a neat conversion function from a group (string <code>new_auto</code>) to a string equal to the name of the category containing it (array object <code>Auto</code>).</p>
  
  <hr>
  
  <p><strong>But as it is, I'm returning the category object, not its name. How can I do this?</strong></p>