Light Mode
Dark Mode
How to return values as a set

I've been able to reverse the keys and values, but I cannot find a way to return the values in a set.

Can someone give me a hint?

Here is my code

function switchDict(data) { let final = {}; for (const [k, v] of Object.entries(data)) { final[v] = []; } for (const [k, v] of Object.entries(data)) { final[v].push(k) } return final }

  • tag:task.switch-keys-to-values
Created: April 13, 2025, 11:59 p.m.
Updated: April 13, 2025, 11:59 p.m.
0
14
User avatar
Rockwell70