Skip to content

Latest commit

 

History

History
33 lines (21 loc) · 573 Bytes

invert.md

File metadata and controls

33 lines (21 loc) · 573 Bytes

objects.invert

invert(object)

Create a new object with key-value pairs inverted, in the case of duplicate values the latter value will overwrite the previous value.

Arguments

  1. object (object): input string

Returns

(object): returns an object with key-value pairs inverted

Example

const result = Objects.invert({ a: 1, b: 2, c: 1 });
console.log(result);
> { '1': 'c', '2': 'b' }