📜  贵公司为每个客户分配一个会员 ID - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:04:07.678000             🧑  作者: Mango

代码示例1
//your company assigns each customer a membership id
function createCheckDigit(membershipId) {
  let arr = membershipId.split('');
  while (arr.length > 1) {
    arr = arr.reduce((count, item) => {
      return count + parseInt(item);
    },0);
    arr = arr.toString().split('');
  }
  return arr[0];
}
 
console.log(createCheckDigit("55555"));