javascript - 如何在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))
解决方案
推荐阅读
- python - 如何找到与 PyPI 条目对应的现有 deb 包?
- http - HTTP mp4 文件传输。IE下载文件太快
- jquery - 在未使用 Select2 的元素上调用了 select2('data') 方法
- python - Pycharm 中的代码问题 - CERTIFICATE_VERIFY_FAILED
- python - 本地很好,但在应用引擎上:ModuleNotFoundError: No module named 'google'
- php - 如何使用 php 解码 base64 电子邮件?
- flutter - 如何将数据列表设置为从 api 到单选按钮和 Dropbox?
- android - 构建 CopperheadOS Android。失败:mkbootfs.o
- complexity-theory - 如何找到n值
- python - numpy 中是否有一种方法可以从 3d 数组中计算每个 2d 数组的平均值?