So this might look like a weird question but bear with me please:
I have a simple array of strings and I want to map it to an array of objects. pretty simple: I would write
arr.map (x => ({
header : x,
sortType: 'basic'
}))
now, here is the question: I would like to check and see if x has a certain value then do not include the sortType at all. I would like to do something like
arr.map (x => ({
header : x,
x==='test' ? (sortType: 'basic') : //don't provide anything
}))
so I would like my final array be something like this: And I do not want to have two maps ofcourse!
[
{ header: 'Header One' , sortType: 'basic'},
{ header: 'test' },
{ header: 'Another one' , sortType: 'basic'},
]