Which Runs Faster?

let array = [];
for(let i = 0; i < 100; i ++) {
    if(i === 10) {
        array[i] = i;
    } else {
        array[i] = i;
    }
}

let sum = 0;
for(let i = 0; i < 1000; i ++) {
    sum += array.reduce((acc, i) => acc + i ?? 0);
}
let array = [];
for(let i = 0; i < 100; i ++) {
    if(i === 10) {
        // array[i] = i;
    } else {
        array[i] = i;
    }
}

let sum = 0;
for(let i = 0; i < 1000; i ++) {
    sum += array.reduce((acc, i) => acc + i ?? 0);
}
https://jsbench.me/2gku4daywx/1

18 / 24