js if多重判断如何优化到最简?
经常碰到循环数组之后需要把某个值转换
```
let arr = res.data.orderinformation;
for (let i = 0; i < arr.length; i++) {
  if (arr[i].ctype == "11001") {
    arr[i].ctype = "微信支付购买";
  } else if (arr[i].ctype == "11008") {
    arr[i].ctype = "余额购买";
  } else if (arr[i].ctype == "11011") {
    arr[i].ctype = "退款到余额";
  } else if (arr[i].ctype == "11012") {
    arr[i].ctype = "优惠卷兑换";
  } else if (arr[i].ctype == "11013") {
    arr[i].ctype = "积分兑换";
  } else if (arr[i].ctype == "11014") {
    arr[i].ctype = "赠送课程";
  }

  // switch优化, 但是这样写不对, 哪里出了问题?
  //   switch (arr[i].ctype) {
  //     case "11001":
  //     arr[i].ctype = "微信支付购买";
  //     break;
  //     case "11008":
  //     arr[i].ctype = "余额购买";
  //     break;
  //     case "11011":
  //     arr[i].ctype = "退款到余额";
  //     break;
  //     case "11012":
  //     arr[i].ctype = "优惠卷兑换";
  //     break;
  //     case "11013":
  //     arr[i].ctype = "积分兑换";
  //     break;
  //     case "11014":
  //     arr[i].ctype = "赠送课程";
  //     break;
  //     default:
  //     break;
  //   } 

  // 用时间戳转成日期
  arr[i].ctime = new Date(arr[i].ctime);
  arr[i].ctime =
    arr[i].ctime.toLocaleDateString().replace(/\//g, "-") +
    " " +
    arr[i].ctime.toTimeString().substr(0, 8);
}
```
```
const d = {
  '11001': '微信支付购买',
  '11008': '余额购买',
  '11011': '退款到余额',
  '11012': '优惠卷兑换',
  '11013': '积分兑换',
  '11014': '赠送课程',
};
for (let i = 0; i < arr.length; i++) {
  if (d[arr[i].ctype]) arr[i].ctype = d[arr[i].ctype];
}
```