diff --git a/snippets/maxDate.md b/snippets/maxDate.md index ffa784528..4b66adb94 100644 --- a/snippets/maxDate.md +++ b/snippets/maxDate.md @@ -2,10 +2,10 @@ Returns the maximum of the given dates. -Use `Math.max.apply()` to find the maximum date value, `new Date()` to convert it to a `Date` object. +Use the ES6 spread syntax with `Math.max` to find the maximum date value, `new Date()` to convert it to a `Date` object. ```js -const maxDate = (...dates) => new Date(Math.max.apply(null, ...dates)); +const maxDate = dates => new Date(Math.max(...dates)); ``` ```js diff --git a/snippets/minDate.md b/snippets/minDate.md index 23cd10e76..1c6b0eebc 100644 --- a/snippets/minDate.md +++ b/snippets/minDate.md @@ -2,10 +2,10 @@ Returns the minimum of the given dates. -Use `Math.min.apply()` to find the minimum date value, `new Date()` to convert it to a `Date` object. +Use the ES6 spread syntax to find the minimum date value, `new Date()` to convert it to a `Date` object. ```js -const minDate = (...dates) => new Date(Math.min.apply(null, ...dates)); +const minDate = dates => new Date(Math.min(...dates)); ``` ```js diff --git a/test/minDate.test.js b/test/minDate.test.js index 21154eb7d..4b5773042 100644 --- a/test/minDate.test.js +++ b/test/minDate.test.js @@ -4,7 +4,7 @@ const {minDate} = require('./_30s.js'); test('minDate is a Function', () => { expect(minDate).toBeInstanceOf(Function); }); -test('minDate produces the maximum date', () => { +test('minDate produces the minimum date', () => { const array = [ new Date(2017, 4, 13), new Date(2018, 2, 12),