title: JavaScript - pushing item to an array based off condition
body: <p>I am looping through my 2 dimensional array and pushing these items into a new array with object titles. I am attempting to change the name of the object based off of a condition.</p>
  <p>Index 1 determines what rank this item is in it's category. I would like to organize my new array and have a condition that reads something like</p>
  <pre><code>    if(data[0][1] === 1) { 
      ' firstRank': data[i][1] 
      } else if (data[0][1] === 2) {
     'secondRank': data[i][1]
     } else if (data[0][1] === 3) {
     'thirdRank': data[i][1]
     }
  </code></pre>
  <p>Here is an example of my code :</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>const data = [
  ["Online", 1 ,3.2 ], 
  ["Appointment", 2 , 2.9],
  ["Store", 3, 1.8],
  ] ;
  
  const newData = []
  
  for (let i = 0; i &lt; data[0].length; i++) {
          newData.push({
              'title': data[i][0],
              'rank': data[i][1],
              'percentage': data[i][2],
          })
      }
      
      
      console.log(newData)</code></pre>
  </div>
  </div>
  </p>
  <p>My expected outcome is for the <code>newData</code> array to have a object rank return as <code>firstRank, secondRank or thirdRank</code> depending on what the value is equal to in the condition. I've attempted to include this rank within my for loop but I getting syntax errors. Here is what i've attempted:</p>
  <pre><code>       for (let i = 0; i &lt; data[0].length; i++) {
              newData.push({
           'title': data[i][0],
          if(data[0][1] === 1) { 
          ' firstRank': data[i][1] 
         } else if (data[0][1] === 2) {
        'secondRank': data[i][1]
        } else if (data[0][1] === 3) {
         'thirdRank': data[i][1]
           }
          'percentage': data[i][2],
              })
          }
  </code></pre>