freeCodeCamp学习:js之实现21点算法

来源:互联网 发布:超市销售量的数据 编辑:程序博客网 时间:2024/06/05 01:29

https://www.freecodecamp.cn/challenges/counting-cards


var count = 0;
function cc(card) {
  // 请把你的代码写在这条注释以下
  switch(card){
    case 2:
    case 3:
    case 4:
    case 5:
    case 6:
      count ++;
      break;
    case 10:
    case "J":
    case "Q":
    case "K":
    case "A":
      count --;
      break;
    default:
      count +=0;
  }
  if (count>0){
    return count+" Bet";
  }else{
    return count+" Hold";
  // 请把你的代码写在这条注释以上
}
}
cc(2); cc(3); cc(4); cc(5); cc(6);