Hi,
I have to analyse a multidimensional array an search for all '0’s and '1’s. The way I did it, in the final the 0s and 1s are presented one by each line. Is it possible to present them on only one line?
The code I used is this:
var validValues = ["0", "1"];
var corruptData = [
["0", "2", "0", "E", "1", "1", "u", "0", "1", "0", ":", "1"],
["0", "0", "1", "9", "0", "}", "1", "l", "1", "1", "1", "˜"],
["x", ".", "d", "2", "|", "[", "z", "8", "s", "d", "2", "5"],
["r", "8", "c", "]", "2", "Z", "H", ";", "Á", "l", "4", "?"],
["Y", "0", "0", "1", "1", "K", "1", ".", "0", "v", "0", "1"]
];
var finalData = [];
for (i=0; i<corruptData.length; i++) {
for (j=0; j<corruptData[i].length; j++) {
if ((corruptData[i])[j] === validValues[0] || (corruptData[i])[j] === validValues[1]) {
finalData.push((corruptData[i])[j]);
}
}
}
console.log(finalData);