s1 = s1.split(i).join(map[i]); を
s1 = s1.replace(new RegExp(i,"mg"),map[i]);にすればいいのかな
全部正規表現による置換になっちゃうけど