我需要 JavaScript 中的一个函数,该函数将一个字符串作为输入,将多个子字符串替换为其对应的值,然后返回结果。例如:
function findreplace(inputStr) {
const values = {"a": "A",
"B": "x",
"c": "C"};
// In this example, if inputStr is "abc", then outputStr should be "AbC".
return outputStr
}
我知道如何单独查找和替换,但我想知道是否有一种简单的方法可以同时处理多对(区分大小写)值。
撒科打诨
交互式爱情
相关分类