题解 | #简单密码#
简单密码
http://www.nowcoder.com/practice/7960b5038a2142a18e27e4c733855dac
var line=readline() var arr=[] for(let i=0;i<line.length;i++){ if(line[i]>='A'&&line[i]<'Z'){
var code=String.fromCharCode(line.charCodeAt(i)+1)
arr[i]=code.toLowerCase()
}else if(line[i]=='Z'){
arr[i]='a'
}else if(line[i]>='0'&&line[i]<='9'){
arr[i]=line[i]
}else{
if(/[a-c]/.test(line[i]))arr[i]='2'
if(/[d-f]/.test(line[i]))arr[i]='3'
if(/[g-i]/.test(line[i]))arr[i]='4'
if(/[j-l]/.test(line[i]))arr[i]='5'
if(/[m-o]/.test(line[i]))arr[i]='6'
if(/[p-s]/.test(line[i]))arr[i]='7'
if(/[t-v]/.test(line[i]))arr[i]='8'
if(/[w-z]/.test(line[i]))arr[i]='9'
}
} console.log(arr.join(''))