How to replace listing five conditions separately with a loop?
I originally wrote it this way, listing them one by one.
The actual situation is much more complex, let me give a simple example:
var af0 = [];
var af1 = [];
var af2 = [];
var af3 = [];
for (var i = 0; i < ps.length; i++) {
if (1 < a) {
bf[1].push(ps[i]);
}
if (2 < a) {
bf[2].push(ps[i]);
}
if (2 < a) {
bf[2].push(ps[i]);
}
}I think it's too complicated and I want to change it like this, but I don't recognize bf [y]
var af0 = [];
var af1 = [];
var af2 = [];
var af3 = [];
for (var i = 0; i < ps.length; i++) {
for (var y = 1; y <= 3; y++) {
if (y < a) {
bf[y].push(ps[i]);
}
}
}I even want to use nested loops to read the values in each bf, but bf [y] [i] can't recognize them anymore.
for (var y = 0; y <= 5; y++) {
for (var i = 0; i < bf[y].length; i++) {
bf[y][i].leading= oldLeading* y;
}
