题解 | #简单密码#
简单密码
https://www.nowcoder.com/practice/7960b5038a2142a18e27e4c733855dac
感觉我使用了 所有用户中最傻的方法去写
var line = readline() var arr = line.split('') var str = '' for(let i=0,len=arr.length;i<len;i++){ if(arr[i] == 'a' || arr[i] == 'b' || arr[i] == 'c'){ str += '2'; }else if(arr[i] == 'd' || arr[i] == 'e' || arr[i] == 'f'){ str += '3'; }else if(arr[i] == 'g' || arr[i] == 'h' || arr[i] == 'i'){ str += '4'; }else if(arr[i] == 'j' || arr[i] == 'k' || arr[i] == 'l'){ str += '5'; }else if(arr[i] == 'm' || arr[i] == 'n' || arr[i] == 'o'){ str += '6'; }else if(arr[i] == 'p' || arr[i] == 'q' || arr[i] == 'r' || arr[i] == 's'){ str += '7'; }else if(arr[i] == 't' || arr[i] == 'u' || arr[i] == 'v' ){ str += '8'; }else if(arr[i] == 'w' || arr[i] == 'x' || arr[i] == 'y' || arr[i] == 'z'){ str += '9'; }else if( arr[i]/1 == arr[i] ){ str += arr[i]; }else{ if(arr[i] == 'Z'){ str += 'A' }else{ str += String.fromCharCode(line.charCodeAt(i) + 1) } } } console.log(str.toLowerCase())