I am facing an issue with a function that maps an array using underscore
. Below is the function in question:
var services = _.map(userCopy.get('services'), function (service) {
if (service.service_selected === true) {
return service;
}
});
The problem arises when the conditional === false
, causing undefined
to be placed into services
. While I can manually remove the undefined
values, it is not ideal and I want to ensure proper usage of the map
function. How can I resolve this issue?