This was bothering me for hours...and I don't understand yet why. I have an array of of objects. Is my syntax bad for the ternary?...
This is in React if that matters.
The array is something like below
[{id:1, name:'steve'}, {id:2, name:'john'}]
if i use this, it works fine.
array.filter(item => { if (item.id ==id) return item.name} )
if I use this, it returns me the whole array, without filtering nothing.
array.filter(item => item.id ===id ? item.name : 'null')
.