How to display a table on one or more lines in the console?

Currenly I need to execute console.log() for tables which contain many item. For tables whith higth length they displayed in the console in one column. I would like to display them in on or more lines. How I have to do ?

The console modules has a lot more than just log. You might want to checkout table. There is also the group method.

1 Like

Hi Kevin,
I tyied to use console.table() in this code but nothing displayed :thinking:

function sumPrimes(num) {
  // Prime number sieve
  let isPrime = Array(num + 1).fill(true);
  // 0 and 1 are not prime
  isPrime[0] = false;
  isPrime[1] = false;
  for (let i = 2; i <= Math.sqrt(num); i++) {
    if (isPrime[i]) {
      // i has not been marked false -- it is prime
      for (let j = i * i; j <= num; j += i)
        isPrime[j] = false;

  // Sum all values still marked prime
  return isPrime.reduce(
    (sum, prime, index) => prime ? sum + index : sum, 0


Did you check the browser console? It will print the table or the error if any issue.

Yeah, it works for me. Like kirankrishnan is saying, make sure you are looking in the browser console. Some online IDE’s have their own “fake” consoles. For example, codepen’s console will show the data but won’t do it as a table.