In my function, there is a map that looks like this:
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 placed the quantityRange()
outside the mainFunc()
and then called it within the ternary operator inside the map. However, upon running the code, I encountered an error: quantityRange()
is not defined. Does this mean we cannot use functions in this way inside the map function in TypeScript?
I would greatly appreciate any assistance with this issue.