我有几个for循环。然而,我的最后一个for循环并没有像预期的那样工作。对于( code_string in match),它应该遍历匹配字符串中的每个代码。
例如,我的输出应该是:
Initial Programming One-time Charge $9.1
Monthly Cost $2.65 但出于某种原因,我看不到我两个都得了9.1分。
为了更好的理解,我附上了一张图片。

for (var key in t.data.codes_prices_array) {
for (code in code_to_match) {
// for ( code_string in match){
//if 251 == 251
if (code_to_match[code] == c.data.codes_prices_array[key].u_charge_code) {
console.log("code to match", code_to_match[code], "u_charge_code", c.data.codes_prices_array[key].u_charge_code);
for ( code_string in match){
//if it is not blank or doesn't have a price of 0 (changed 2013-2-6)
if ( c.data.codes_prices_array[key].u_price!= '' && c.data.codes_prices_array[key] != 0){
strVal = strVal.replace(match[code_string], "$" + c.data.codes_prices_array[key].u_price);
t.data.u_pricing = strVal;
console.log("MONTHLY PRICE", match[code_string], "$" + c.data.codes_prices_array[key].u_price);
}
else{
strVal = strVal.replace(match[code_string], "$" + c.data.codes_prices_array[key].u_one_time_charge);
t.data.u_pricing = strVal;
console.log("ONE TIME ", match[code_string], "$" + c.data.codes_prices_array[key].u_one_time_charge);
}
}
}
}
}
https://stackoverflow.com/questions/47540154
复制相似问题