Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save arrbxr/444bc36c4a1c5001181e7296c5cae913 to your computer and use it in GitHub Desktop.

Select an option

Save arrbxr/444bc36c4a1c5001181e7296c5cae913 to your computer and use it in GitHub Desktop.
Multi-tap Keypad Text Entry on an Old Mobile Phone created by arrbxr - https://repl.it/@arrbxr/Multi-tap-Keypad-Text-Entry-on-an-Old-Mobile-Phone
function ravi(st){
var one = 0;
var two =0;
var three =0;
var four = 0;
var str = st.toLowerCase().split('');
for(var i = 0; i<str.length; i++){
if(str[i] == 'a' || str[i] == 'd' || str[i] == 'g' ||str[i] == 'j' || str[i]== 'm' || str[i] == 'p' ||str[i]=='t' || str[i] == 'w' || str[i] == " "){
one += 1;
}
else if(str[i]=='b' || str[i]=='e' || str[i]=='h' || str[i]=='k' || str[i]=='n' || str[i]=='q' || str[i] == 'u' || str[i]=='x'){
two += 2;
}
else if(str[i]=='c'|| str[i]=='f' || str[i]=='i' || str[i]=='l'||str[i]=='o'||str[i]=='r'||str[i]=='v'|| str[i]=='y'){
three += 3;
}
else
four += 4;
}
return one + two + three + four;
}
ravi("how R U");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment