Console the result in one line

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);

Don’t use an array. Otherwise, don’t use console.log() as its purpose as a debugging tool is to provide structured and verbose data.

I converted it to a string using “*.join()”, it’s ok now.
Thanks for the reply :slight_smile:

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.