Skip to content

Instantly share code, notes, and snippets.

@thacherhussain
Created February 9, 2017 20:27
Show Gist options
  • Save thacherhussain/8751a74fbf41f975b516919a48f00fe2 to your computer and use it in GitHub Desktop.
Save thacherhussain/8751a74fbf41f975b516919a48f00fe2 to your computer and use it in GitHub Desktop.
Translation Logic
//Top array is simulated input
var array = ['at&t', 'ATT', 'att', 'tmobile', 'T-mobile', 'TMobile', 'Tesla'];
var endArray = [];
for(var i = 0; i < array.length; i++) {
switch(array[i]){
case 'at&t':
endArray[i] = 'AT&T';
break;
case 'ATT':
endArray[i] = 'AT&T';
break;
case 'att':
endArray[i] = 'AT&T';
break;
case 'tmobile':
endArray[i] = 'T-Mobile';
break;
case 'T-mobile':
endArray[i] = 'T-Mobile';
break;
case 'TMobile':
endArray[i] = 'T-Mobile';
break;
default:
endArray[i] = array[i];
}
}
console.log(endArray);
console.log(array);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment