题解 |JS23 验证是否是身份证
const _isCard = number => {
// 补全代码
const length = number.length;
if(length !== 18){
return false;
}
for(let i = 0;i < length-1; i++){
if(number[i] > '9' || number[i] < '0'){
return false;
}
}
if(number[length-1]=== 'X' || (number[length -1] > '0' && number[length-1] < '9')){
return true;
}else{
return false;
}
}