I have the following map within a function:
mainFunc(){
// other logics
data.map(function (item) {
item.number = Math.round(item.number);
item.total = item.last - item.first;
item.quantity= item?.quantity ? quantityRange(item?.quantity): '';
});
// other logics
}
quantityRange(quantity){
if(quantity){
if(quantity < 100) return "Less Quantity";
if(quantity < 500) return "Average Quantity";
else return "Good Quantity"
}
}
I have the quantityRange()
outside the mainFunc()
and I am calling it inside the ternary operator inside the map. When I run my code I get the error: quantityRange()
not defined. Can we not use functions like this inside the map in typescript?
Any help would be appreciated.