-1
有沒有辦法循環這段代碼並改變數字(i = 1,2,3)以避免重複?javascript改變字符串中的數字
if (bool) {
reeks1Getallen = reeks1.splice(0, k1 % (reeks1.length));
reeks2Getallen = reeks2.splice(0, k2 % (reeks2.length));
reeks3Getallen = reeks3.splice(0, k3 % (reeks3.length));
} else {
reeks1Getallen = reeks1.splice(0, (reeks1.length) - k1 % reeks1.length);
reeks2Getallen = reeks2.splice(0, (reeks2.length) - k2 % reeks2.length);
reeks3Getallen = reeks3.splice(0, (reeks3.length) - k3 % reeks3.length);
}
reeks1 = reeks1.concat(reeks1Getallen);
reeks2 = reeks2.concat(reeks2Getallen);
reeks3 = reeks3.concat(reeks3Getallen);
不要使用不同的變量名稱。使用數組var'reeks = [...]' – Bergi
每個語句中有3個字符串變化,我不會避免與1個單個數組重複,對嗎? @Bergi –
我在這些語句中沒有看到任何字符串? – Bergi