I am facing an issue with using the forEach method on an array. Despite it being a mutator, it is not mutating the values in the original array as expected. Can anyone help me figure out what could be causing this problem?
let array = [1, 2, 3, 4]; //declaring a simple array
array.forEach((ele) => ele * 2); //using forEach to double each element in "array"
console.log(array); //expecting [1, 4, 6, 8] but getting [1, 2, 3, 4] instead
Any insights on why this is happening?