title: Format input from M/D/YYYY to YYYYMMDD
body: <p>Write a function that converts user entered date formatted as <strong>M/D/YYYY</strong> to a format required by an API (<strong>YYYYMMDD</strong>). The parameter "<code>userDate</code>" and the return value are strings.</p>
  
  <p>For example, it should convert user entered date <strong>"12/31/2014" to "20141231"</strong> suitable for the API.</p>
  
  <pre><code>function formatDate(userDate) 
  {
       userDate = new Date();
       y = userDate.getFullYear();
       m = userDate.getMonth();
       d = userDate.getDate();
  
       return y + m + d;
  }
  </code></pre>
  
  <p>is there anything wrong with my code? </p>
  
  <p>couldn't pass an online test.</p>