title: How to convert imperial to metric units?
body: <p>This is more of a general question of both code and math. I'm not at all good at math, and I'm still learning how to apply math in programming.</p>
  
  <p>Let's say, I have an object of data that has the amount, the measurement, and the type, such as <code>feet</code> or <code>lb</code>.</p>
  
  <pre><code>const data = {
    0: {
      'type': 'imperial',
      'unit': 'ft',
      'amount': 3 
    },
    1: {
      'type': 'imperial',
      'unit': 'lb',
      'amount': 5
    },
    2: {
      'type': 'imperial',
      'unit': 'mph',
      'amount': 7 
    }
  }
  </code></pre>
  
  <p>And I need to go through this data and convert each according to the type (assuming type is what it's called)</p>
  
  <pre><code>Object.keys(data).map(key =&gt; {
      convert(data[key]['amount'], data[key]['type'], data[key]['unit'])
  })
  </code></pre>
  
  <p>And the function converts this:</p>
  
  <pre><code>const convert = (amount, type, unit) =&gt; {
     const calc = // ???
     return calc;
  }
  </code></pre>
  
  <p>My question is, how do I convert depending on the type of measurement? I know that 1 foot is 0.3048 meters, and if I needed to convert 5 feet to meters, I'd do <code>5*0.3048</code>.</p>
  
  <p>However, how can I apply this in code, with a list of imperial and metric units and how would I add this to the convert function?</p>