Write .invert()
This commit is contained in:
parent
3b69d25b8d
commit
b81771fae3
1 changed files with 12 additions and 2 deletions
14
lodash/_.js
14
lodash/_.js
|
@ -40,8 +40,18 @@ _.pad = function (string, length) {
|
|||
|
||||
/* ----------------------------------------------------------------- has ---- */
|
||||
|
||||
_.has = function (obj, key) {
|
||||
return !!obj[key]
|
||||
_.has = (obj, key) => !!obj[key]
|
||||
|
||||
/* -------------------------------------------------------------- invert ---- */
|
||||
|
||||
_.invert = function (obj) {
|
||||
const newObj = {}
|
||||
|
||||
for (const key in obj) {
|
||||
newObj[obj[key]] = key
|
||||
}
|
||||
|
||||
return newObj
|
||||
}
|
||||
|
||||
// Do not write or modify code below this line.
|
||||
|
|
Loading…
Reference in a new issue