-
-
Notifications
You must be signed in to change notification settings - Fork 9.1k
lc/2822/ #3637
lc/2822/
#3637
-
Beta Was this translation helpful? Give feedback.
All reactions
Replies: 1 comment
-
function solve(obj) { let temp = { ...obj }; const res = {}; Object.entries(temp).forEach(([key, val]) => { if (res[val] === undefined) res[val] = key; else if (Array.isArray(res[val])) res[val].push(key); else res[val] = [res[val], key]; }); return res; }
Beta Was this translation helpful? Give feedback.
All reactions
-
👍 1
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment