I need to delete some columns in a 2d array. The list is named as hiddenCols
var array = [
["a", "b", "c"],
["a", "b", "c"],
["a", "b", "c"]
]
hiddenCols = [3, 1] // these are pos and not indexes
for (var j = 0; j < array.length; j++) {
for (var i = 0; i < hiddenCols.length; i++) {
array[j].splice(hiddenCols[i], hiddenCols[i])
}
}
console.log(JSON.stringify(array));
The expected result is var array = [["b"],["b"],["b"]];
for (var j = 0; i < array.length; i++) {the variablejis declared as a loop variable butiis used in the check for termination.