I've got a function in an object like this:
arrayofElements: function(item) {
var result = [];
if (item.isA) {
result.push(new Div('aClass', labels['A']));
}
if (item.isC) {
result.push(new Div('cClass', labels['C']));
}
if (item.isD) {
result.push(new Div('dClass', labels['D']));
}
return result;
},
How can this be refactored? I dislike having to push() each item conditionally.