File tree Expand file tree Collapse file tree 1 file changed +2
-6
lines changed
src/algorithms/sorting/counting-sort/__test__ Expand file tree Collapse file tree 1 file changed +2
-6
lines changed Original file line number Diff line number Diff line change @@ -27,14 +27,10 @@ describe('CountingSort', () => {
27
27
const sorter = new CountingSort ( { visitingCallback } ) ;
28
28
29
29
// Detect biggest number in array in prior.
30
- const biggestElement = notSortedArr . reduce ( ( accumulator , element ) => {
31
- return element > accumulator ? element : accumulator ;
32
- } , 0 ) ;
30
+ const biggestElement = Math . max ( ...notSortedArr ) ;
33
31
34
32
// Detect smallest number in array in prior.
35
- const smallestElement = notSortedArr . reduce ( ( accumulator , element ) => {
36
- return element < accumulator ? element : accumulator ;
37
- } , 0 ) ;
33
+ const smallestElement = Math . min ( ...notSortedArr ) ;
38
34
39
35
const sortedArray = sorter . sort ( notSortedArr , smallestElement , biggestElement ) ;
40
36
You can’t perform that action at this time.
0 commit comments