I want to retain the array instead of creating a new one (which map does), hence, I'm doing the following using forEach. But none of my comparisons are going through and the array remains the same.
const array1 = [1, 2, 3];
array1.forEach(element => element < 2 ? 0 : element);
//array1.forEach(element => element + 2);
console.log(array1);
The result should be array1 = [0, 2, 3];
Is my understanding of how it works incorrect?