如果输入值“ dx”不在数组中,我需要在价格“ CenyIndR”中增加百分比的帮助。
示例:
输入dx = 300,konk =“ VKM”
315 i = 0的输出返回价格并加10%= 508 * 1.1 = 558.8
我尝试将var Indexy添加到函数custom()并添加
else if(Indexy[i][0] !==dx) return CenyIndR[i][ind+1]*1.1;
但是结果是,它为所有内容增加了10%,而不仅仅是数组之外的值。
JS:
function index(d) {
var Indexy = [
[100, 0],
[125, 1],
[160, 2],
[200, 3],
[250, 4],
[315, 5],
[400, 6],
[500, 7],
[630, 8]
[710, 9],
[800, 10],
[-1, -1]
];
for (i = 0; Indexy[i][0] > 0; i++) {
if (Indexy[i][0] >= d) {
return Indexy[i][1];
}
}
return -1;
}
function custom()
{
ovl = parameter0;
dx = parameter1;
mat = parameter2;
konk = parameter3;
var CenyIndR = [
[1,230,242,257,254,482,508, 673,1102,1505,4085,5887],
[2,267,284,309,319,540,622, 823,1311,1917,5720,6264],
[-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1]
];
var ind = index(dx);
if ( ind < 0 )
return 0;
if(konk=="VKM") i=0;
else if(konk=="VKT") i=1;
else if(konk=="KPL") i=0;
else if(konk=="KPW") i=0;
else return 0;
if (mat=="ne") return 0;
else if(ovl=="R"||ovl=="S") return CenyIndR[i][ind+1];
else return 0;
return 0;
}
custom();