var locals = ['101','1500','hello',
'102','1500','helloworld',
'103','700','helloworld!!!'];
for (var n = 0; n < (locals.length); n++) {
console.log(n);
console.log(
JSON.stringify(locals[3 * n]),
JSON.stringify(locals[3 * n + 2]),
JSON.stringify(locals[3 * n + 1])
)
}
n < locals.length
сделайте n < locals.length / 3
.3 * n
будет просто n
, вместо 3 * n + 1
будет n + 1
, и т.д. if (JSON.stringify(locals[3 * n]) === undefined) break;
var locals = ['101','1500','hello',
'102','1500','helloworld',
'103','1500','hello',
'104','1500','helloworld',
'105','700','helloworld!!!'];
for (var n = 0; n < (locals.length); n++) {
if (JSON.stringify(locals[3 * n]) === undefined) break;
console.log(n);
console.log(
JSON.stringify(locals[3 * n]),
JSON.stringify(locals[3 * n + 2]),
JSON.stringify(locals[3 * n + 1])
)
}