I am creating an object which has few keys to it .
processData = memoize(
({
data,
group
}:EnumValues): Array<ITypeData> => {
return _.map(test, (test: ITest) => ({
id: test.Id,
name: test.Name,
code: test.Code,
}))
Here I am creating the object. Here there is a key called code, so if I don't want to have this key if there is no group data available or that is not sent. as this processData function is getting called from two places where from one place it gets that group data and from another not getting.
I tried:
code : test && test.Code
but still it doesn't work. Is there another way to handle this?