* turns * { 'MUCH ERROR': '0', 'SUCH WRONG': '1' } * into * { 0: 'MUCH ERROR', 1: 'SUCH WRONG' }
(targetObj)
| 13 | * { 0: 'MUCH ERROR', 1: 'SUCH WRONG' } |
| 14 | */ |
| 15 | function invertObject(targetObj) { |
| 16 | const result = {}; |
| 17 | const mapKeys = Object.keys(targetObj); |
| 18 | |
| 19 | // eslint-disable-next-line no-for-of-loops/no-for-of-loops |
| 20 | for (const originalKey of mapKeys) { |
| 21 | const originalVal = targetObj[originalKey]; |
| 22 | |
| 23 | result[originalVal] = originalKey; |
| 24 | } |
| 25 | |
| 26 | return result; |
| 27 | } |
| 28 | |
| 29 | module.exports = invertObject; |
no test coverage detected