title: JavaScript map array using JSON file
body: <p>In JavaScript I have an array of three letter codes and I have a JSON file that has values for each of these codes. I need to map the codes to the corresponding values in the JSON file.
  Here's an example:</p>
  
  <pre><code>{"Roles" : [
  {"code": "cmm", "fullname": "commentator"},
  {"code": "cmp", "fullname": "composer"},
  {"code": "cnd", "fullname": "conductor"},
  {"code": "cng", "fullname": "cinematographer"},
  {"code": "cns", "fullname": "censor"},
  {"code": "com", "fullname": "compiler"}
  ]}
  
  var arr = ["cmm", "com", "cng"];
  var mappedArray = arr.map( ??? );
  
  //mappedArray now contains: ["commentator", "composer", "cinematographer"]
  </code></pre>
  
  <p>I can't think of a way of solving this that isn't horribly inefficient. Can anyone help?</p>