I have an array of objects:
const arr = [{name: ''}]
I want to map over this array and, if name value is "" (empty string), I want the result to be an empty array [].
If it has values, then I want the result to be an array with the values (eg. ["Rick"]
I've tried to have a fallback value but the result is still [""]
My attempt:
const result = arr.map(a => a.name) || []
Actual result: [""]
Desired result: []
result = arr.filter(a => a.name).map(a => a.name) || []