题解 | #简单密码#
简单密码
http://www.nowcoder.com/practice/7960b5038a2142a18e27e4c733855dac
let text = readline();
const arr = ['abc',2,'def',3,'ghi',4,'jkl',5,'mno',6,'pqrs',7,'tuv',8,'wxyz',9]
text = text.replace(/[(a-z)]/g,a => {
for(let i=0;i<arr.length;i++){
if(typeof arr[i] == 'string' && arr[i].indexOf(a) != -1){
return arr[i+1]
}
}
})
text = text.replace(/([A-Z])/g,a => {
if(a == 'Z'){
return 'a'
}else {
return String.fromCharCode(a.toLowerCase().charCodeAt(0)+1)
}
})
console.log(text)