My task involves modifying an array before sending it to an API that only requires the IDs. The initial array contains both true and false values based on user interaction with the UI.
[2: true, 3: true, 5: true]
However, in some instances, the array appears like this:
[1: false, 2: true, 3: true, 5: true, 6: false]
I need a way to filter out the false values and keep only the IDs, resulting in the desired data format:
[2, 3, 5]