I'm new on JavaScript and I'm trying to remove an array of the array if there is a letter
Ex: [["x","y", 2],[2, 4],[5, 3],[6, 9],["a", 1]]
The expected output would be: [[2, 4],[5, 3],[6, 9]]
;
In your case I think the problem is inner loop. Because data[i][j]
will "x","y",2,4,5...
and you can't apply indexOf()
to numbers so it throws error.
You can use use Array.prototype.every()
inside Array.prototype.filter()
var data = [["y","x",2],[2, 4],[5, 3],[6, 9]]
let res = data.filter(x => x.every(x =>!isNaN(x)));
console.log(res)