How to jot down in a row all the keys with non-empty value of the object?

Is the object props, it includes properties with a value of either empty(null, "). What is the best way to get rid of this object to output a string with all keys separated by a comma( after the last comma should not be there)?
March 23rd 20 at 19:11
1 answer
March 23rd 20 at 19:13
Solution
Object.entries(props).filter(n => n[1]).map(n => n[0]).join(',')

or

`${Object.entries(props).reduce((acc, [ k, v ]) => (v && acc.push(k), acc), [])}`

or

"+ Object.keys(props).reduce((acc, n) => props[n] ? [ ...acc, n ] : acc, [])

or

String(Object.keys(props).filter(n => props[n]))
Thank you!) The latter is simply a work of art) - Enoch.Gutkowsk commented on March 23rd 20 at 19:16
But I did and thought what better way
let notEpmty = ";
 for (key in props){
 props[key]? notEpmty +=`${key}, ` : null;
}
- Enoch.Gutkowsk commented on March 23rd 20 at 19:19

Find more questions by tags JavaScript