首页 > 解决方案 > 如何在javascript中替换多个字符串?

问题描述

嗨我如何在javascript中替换多个字符串?例如替换 1 到 34 和 2 到 37

 function code(str){
   str.replace('1','34');str.replace('2','37');str.replace('3','36');str.replace('4','31');str.replace('5','30');str.replace('6','33');str.replace('7','32');str.replace('8','3d');str.replace('9','3c');str.replace('0','35');

    return str;
}
console.log(code(123))

标签: javascriptjquery

解决方案


推荐阅读