please tell me how to make this function smaller how can i combine map reduse and if check in one function
const items = [
{ prise: 40 },
{ prise: -120 },
{ prise: "505" },
{ prise: 350 },
];
const isType = (item) => {
if (typeof item.prise === "number" && item.prise > 0) {
return item.prise;
}
return 0;
};
const sum = items.map((key) => {
return isType(key);
});
const total = sum.reduce((acc, item) => acc + item);