JavaScript Strings Public



Write a function that converts user entered date formatted as M/D/YYYY to a format required by an API (YYYYMMDD). The parameter "userDate" and the return value are strings.

For example, it should convert user entered date "12/31/2014" to "20141231" suitable for the API.

ECMAScript 6

  •   Example case: Wrong answer
  •   Two-digit month and day: Wrong answer
  •   One-digit day: Wrong answer
  •   One-digit month: Wrong answer