Groups the elements of an array based on the given function.
Use Array.map() to map the values of an array to a function or property name. Use Array.reduce() to create an object, where the keys are produced from the mapped results.
const groupBy = (arr, func) =>
arr.map(typeof func === 'function' ? func : val => val[func]).reduce((acc, val, i) => {
acc[val] = (acc[val] || []).concat(arr[i]);
diff --git a/snippets/forEachRight.md b/snippets/forEachRight.md
index 15f205209..cfda33a56 100644
--- a/snippets/forEachRight.md
+++ b/snippets/forEachRight.md
@@ -5,9 +5,13 @@ Executes a provided function once for each array element, starting from the arra
Use `Array.slice(0)` to clone the given array, `Array.reverse()` to reverse it and `Array.forEach()` to iterate over the reversed array.
```js
-const forEachRight = (arr,callback) => arr.slice(0).reverse().forEach(callback);
+const forEachRight = (arr, callback) =>
+ arr
+ .slice(0)
+ .reverse()
+ .forEach(callback);
```
```js
-forEachRight([1,2,3,4], val => console.log(val)); // '4', '3', '2', '1'
+forEachRight([1, 2, 3, 4], val => console.log(val)); // '4', '3', '2', '1'
```