title: Using Javascript Array Properties to restrict a random output
body: <p>I am trying to build a random mission selector for my local group's Warhammer 40k Discord.</p>
  <p>So far I can out put any mission when the function is called - but I would like users to be able to select parameters to restrict the output to only those mission which match the criteria.</p>
  <p>For example - when they type: !mission Combat Patrol- only Battle Size (mission.size) properites which match Combat Patrol should be randomly selected from. Ideally this would work regardless of how many variables are restricted (eg. !mission Combat Patrol BRB, or !mission BRB Combat Patrol would both limit the array search to mission from mission.size Combat Patrol and mission.source BRB). And, if there is no match the option is ignored (eg !mission NotPresent will still choose from all missions, !mission NotPresent Combat Patrol will only show Combat Patrol missions).</p>
  <p>Is this possible?</p>
  <p>Thanks in advance!</p>
  <p>Here is my code so far:</p>
  <pre><code>module.exports = { 
      name: 'mission', 
      description: 'Randomly selects a mission', 
  
       execute(message, args) { 
         let missionArray = [
             {
                 name: &quot;Incisive Attack&quot;,
                 size: &quot;Combat Patrol&quot;,
                 type: &quot;Eternal War&quot;,
                 source: &quot;BRB&quot;,
                 page: &quot;286&quot;
                 
             },
             {
              name: &quot;Outriders Attack&quot;,
              size: &quot;Combat Patrol&quot;,
              type: &quot;Eternal War&quot;,
              source: &quot;BRB&quot;,
              page: &quot;287&quot;
              
          },
          //more missions go here
          {
              name: &quot;Pathway to Glory&quot;,
              size: &quot;Onslaught&quot;,
              type: &quot;Eternal War&quot;,
              source: &quot;BRB&quot;,
              page: &quot;303&quot;,
          }
              ]; 
        
              let mission = missionArray[Math.floor(Math.random() * missionArray.length)];
         
  
         return message.reply(`I have consulted the mission8Ball and you will play:\n**${mission.name}**\nMission Type: ${mission.type}\nBattle Size: ${mission.size}\nSource: ${mission.source}\nPage: ${mission.page}`); 
       }, 
     }; 
  </code></pre>