Let's consider an array with values: [[10, 20, 30, 20, 50], [40, 50, 60, 20, 20], [70, 80, 90, 20, 20], [70, 80, 90, 20, 20]];
In this case, the task is to remove all elements that equal 50 from the subarrays.
The desired resulting array would be: [[10, 30, 20], [40, 60, 20], [70, 90, 20], [70, 90, 20]];
An attempted solution using a nested loop to iterate through and delete elements where value equals to 50 was not successful.
for (var i = 0; i < array.length; i++) {
for (var j = 0; j < array[i].length; j++) {
if (array[i][j] == 50) {
array[i].splice(j, 1);
}
}
}