Repository navigation
#234 Date Format
Adam Kubiś edited this page Oct 28, 2026
·
1 revision
Create a function that converts a date formatted as MM/DD/YYYY to YYYYDDMM.
Current source and tests | Catalog | Testing and tooling
From the cloned repository root, after installing dependencies:
node "Edabit/234 Date Format.js"Assertions are kept alongside the implementation and throw on failure. A successful run exits with code 0. Run every exercise with npm test or both lint and tests with npm run check.
This is the complete executable file, including its imports and inline test cases. Run it from the repository, not as an isolated file copied out of the wiki. Line endings and trailing whitespace are normalized; executable tokens are unchanged.
//Create a function that converts a date formatted as MM/DD/YYYY to YYYYDDMM.
function formatDate(date) {
return date.split('/').reverse().join('');
}
import { assertEquals } from '../testHelper.js';
assertEquals(formatDate("11/12/2019"), "20191211")
assertEquals(formatDate("12/31/2019"), "20193112")
assertEquals(formatDate("01/15/2019"), "20191501")