for usual | const array = [920, 168, 892, 195, 205, 494, 145, 501, 722, 700, 658, 452, 639, 394, 463, 421, 478, 824, 840, 697, 176, 984, 744, 451, 292, 907, 935, 446, 171, 640, 408, 66, 918, 414, 568, 650, 490, 25, 177, 353, 481, 494, 293, 844, 237, 329, 818, 67, 331, 982, 400, 496, 82, 584, 96, 657, 378, 751, 222, 843, 625, 106, 648, 25, 579, 18, 157, 88, 936, 56, 988, 68, 675, 961, 760, 632, 289, 918, 861, 2, 993, 426, 431, 391, 981, 589, 818, 940, 716, 478, 556, 473, 989, 771, 467, 790, 838, 935, 200, 815];
let sum = 0;
for (let index = 0; index < array.length; index++) {
sum += array[index];
}
| ready |
for reverse | const array = [920, 168, 892, 195, 205, 494, 145, 501, 722, 700, 658, 452, 639, 394, 463, 421, 478, 824, 840, 697, 176, 984, 744, 451, 292, 907, 935, 446, 171, 640, 408, 66, 918, 414, 568, 650, 490, 25, 177, 353, 481, 494, 293, 844, 237, 329, 818, 67, 331, 982, 400, 496, 82, 584, 96, 657, 378, 751, 222, 843, 625, 106, 648, 25, 579, 18, 157, 88, 936, 56, 988, 68, 675, 961, 760, 632, 289, 918, 861, 2, 993, 426, 431, 391, 981, 589, 818, 940, 716, 478, 556, 473, 989, 771, 467, 790, 838, 935, 200, 815];
let sum = 0;
for (let index = array.length - 1; index >=0 ; index--) {
sum += array[index];
}
| ready |
forEach | const array = [920, 168, 892, 195, 205, 494, 145, 501, 722, 700, 658, 452, 639, 394, 463, 421, 478, 824, 840, 697, 176, 984, 744, 451, 292, 907, 935, 446, 171, 640, 408, 66, 918, 414, 568, 650, 490, 25, 177, 353, 481, 494, 293, 844, 237, 329, 818, 67, 331, 982, 400, 496, 82, 584, 96, 657, 378, 751, 222, 843, 625, 106, 648, 25, 579, 18, 157, 88, 936, 56, 988, 68, 675, 961, 760, 632, 289, 918, 861, 2, 993, 426, 431, 391, 981, 589, 818, 940, 716, 478, 556, 473, 989, 771, 467, 790, 838, 935, 200, 815];
let sum = 0;
array.forEach(element => {
sum += element;
});
| ready |
for usual with length constant | const array = [920, 168, 892, 195, 205, 494, 145, 501, 722, 700, 658, 452, 639, 394, 463, 421, 478, 824, 840, 697, 176, 984, 744, 451, 292, 907, 935, 446, 171, 640, 408, 66, 918, 414, 568, 650, 490, 25, 177, 353, 481, 494, 293, 844, 237, 329, 818, 67, 331, 982, 400, 496, 82, 584, 96, 657, 378, 751, 222, 843, 625, 106, 648, 25, 579, 18, 157, 88, 936, 56, 988, 68, 675, 961, 760, 632, 289, 918, 861, 2, 993, 426, 431, 391, 981, 589, 818, 940, 716, 478, 556, 473, 989, 771, 467, 790, 838, 935, 200, 815];
const len = array.length;
let sum = 0;
for (let index = 0; index < len; index++) {
sum += array[index];
}
| ready |