Another ES6 JavaScript solution

37 bytes for a single use function.
41 bytes for a multi-use function.