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 function like this inside the map in typescript?
Any help would be appreciated.