Javascript / Senior Front-end Developer
Interview Test
Share your answers as Markdown through Gist and include code as Markdown code blocks. No worries, there is more than one way to answer the questions
Q1
Write a function (without using external libraries) in ES6 that converts the user entered date formatted as M/D/YYYY
to the format YYYYMMDD
which is required by an API endpoint. It should convert ”12/31/2016”
to ”20161231”
for example. Furthermore, it should validate that the passed date is formatted correctly using a Regular Expression (let's assume all months have 31 days). Write unit tests for your convert function using the syntax of a BDD-style test framework of your choice.
mocha.setup('bdd');