TODO: Write solution to main task Module 2!
- Set the O variable to be an Object cast of the this value (array the function was used on)
- Set the len variable to be the length of the O Object, which is an ArrayLike (essentially a list).
- Check the callbackfn passed into the function, if it is not callable (if it essentially isn't a function) throw an TypeError
- Set the value k to be 0
- Create a list titled groups
- Iterate len times:
- Convert K into a String in order to use it to get the aproporiate Value from O
- Set kValue to be the value located at k index in the list
- Use the callbackfn defined in the function parameter to convert the kValue to it's group key. Put that value into variable propertyKey
- Use the AddValueToKeyedGroup function defined below to add the value into the list groups
- Increment k
- Create an ordinary JavaScript Object, which inherits from
Objectand put it into the variable obj. - For each (key, [value]) in groups:
- Create an array from the elements corresponding to the current key
- Create a property on the ordinary object created on step 7, if error: throw said error.
- Return the created object