I couldn't find a function resembling Ruby's tr or PHP's strtr in JavaScript, so I created one. Here's the code:
function tr(str, from, to) {
var subst;
for (i = 0; i < from.length; i++) {
subst = (to[i]) ? to[i] : to[to.length-1];
str = str.replace(new RegExp(str[str.indexOf(from[i])], 'g'), subst);
}
return str;
}