I have the following JavaScript code where I am displaying different status based on the response key from an API. Is there a more efficient approach to optimize this code so that I don't have to check each case with IF, especially if the number of statuses increases?
if (data.shippingStatus) {
let shippingStatus = data.shippingStatus.toString();
const statusMap = {
"AWAITING_SHIPMENT": "Awaiting Shipment",
"SHIPPED": "Shipped",
"DELIVERED": "Delivered",
"CANCELLED": "Cancelled"
};
shippingStatus = statusMap[shippingStatus] || "";
resData.push(setData(data.shippingStatus ? shippingStatus : ""));
}