--- title: Date format id: 59669d08d75b60482359409f localeTitle: 59669d08d75b60482359409f challengeType: 5 --- ## Description
Tarea:

Devuelve una matriz con la fecha actual en los formatos:

- 2007-11-23 y

- Domingo 23 de noviembre de 2007.

Salida de ejemplo: ['2007-11-23', 'Sunday, November 23, 2007']

## Instructions
## Tests
```yml tests: - text: getDateFormats es una funciĆ³n. testString: 'assert(typeof getDateFormats === "function", "getDateFormats is a function.");' - text: Debe devolver un objeto. testString: 'assert(typeof getDateFormats() === "object", "Should return an object.");' - text: Debe devolverse una matriz con 2 elementos. testString: 'assert(getDateFormats().length === 2, "Should returned an array with 2 elements.");' - text: Debe devolver la fecha correcta en el formato correcto. testString: 'assert.deepEqual(getDateFormats(), dates, equalsMessage);' ```
## Challenge Seed
```js function getDateFormats () { // Good luck! return true; } ```
### After Test
```js console.info('after the test'); ```
## Solution
```js function getDateFormats () { const date = new Date(); const weekdays = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']; const months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']; const fmt1 = `${date.getFullYear()}-${(1 + date.getMonth())}-${date.getDate()}`; const fmt2 = `${weekdays[date.getDay()]}, ${months[date.getMonth()]} ${date.getDate()}, ${date.getFullYear()}`; return [fmt1, fmt2]; } ```