Write a program to find the mode value of a collection.
The case where the collection is empty may be ignored. Care must be taken to handle the case where the mode is non-unique.
If it is not appropriate or possible to support a general collection, use a vector (array), if possible. If it is not appropriate or possible to support an unspecified value type, use integers.
mode
is a function.
testString: 'assert(typeof mode === "function", "mode
is a function.");'
- text: 'mode([1, 3, 6, 6, 6, 6, 7, 7, 12, 12, 17])
should equal [6]
'
testString: 'assert.deepEqual(mode(arr1), [6], "mode([1, 3, 6, 6, 6, 6, 7, 7, 12, 12, 17])
should equal [6]
");'
- text: 'mode([1, 2, 4, 4, 1])
should equal [1, 4]
.'
testString: 'assert.deepEqual(mode(arr2).sort(), [1, 4], "mode([1, 2, 4, 4, 1])
should equal [1, 4]
.");'
```