Question: This program is a basic attempt at finding a pair of twin primes each, before and after a given numerical value on the whole number line.The code looks good but is not giving any output and neither is it terminating post a run.I would like to know what is wrong with it.Thanks! 

```
public class twin {

    public boolean prime(int num) { // function to check for a prime number

        if (num % 2 == 1 && (num % 3 == 2 || num % 3 == 1)) {
            return true;

        } else
            return false;

    }

    public static void main(String args[]) { // main
        int inp_num = 7; // given number too check for twin primes before or
                            // after it
        twin ob = new twin();
        int arr[] = new int[5];
        for (int x = inp_num; x > 0; x--) { // checking limit [o,inpnum)
            boolean b = ob.prime(x);
            if (b = true) {
                if (ob.prime(x - 2) == true) {
                    arr[0] = x;
                    arr[1] = x - 2;
                }

            }

        }
        for (int x = inp_num; x >= inp_num; x++) { // checking limit
                                                    // [inpnum,infinity]
            boolean b = ob.prime(x);
            if (b = true) {

                if (ob.prime(x + 2) == true) {
                    arr[2] = x;
                    arr[3] = x + 2;
                }

            }

        }
        for (int i = 0; i < 4; i++) {
            System.out.println(arr[i] + "\t");

        }
    }
}

```

Answer: 
Here's my ES6 soulution with math error handling:

```js
const matrixDot = (A, B) => {
  // Error handling
  const mx = [A, B];
  const cols = mx.map((matrix) => matrix[0].length);
  if (!mx.every((matrix, i) => matrix.every((row) => row.length === cols[i]))) {
    throw new Error(
      'All rows in a matrix must have the same number of columns'
    );
  } else if (cols[0] !== B.length) {
    throw new Error(
      'The number of columns in the 1st matrix must be equal to the number of rows in the 2nd matrix'
    );
  }

  // Calculations
  return A.map((rowA) =>
    B[0].map((_, xb) =>
      rowA.reduce((acc, itemA, yb) => acc + itemA * B[yb][xb], 0)
    )
  );
};

// Example
const A = [
  [3, 2, 5],
  [6, 4, 1],
];
const B = [
  [2, 6],
  [5, 3],
  [1, 4],
];
console.log(matrixDot(A, B));
```

Hope it helps somebody ;)
UP =)

```
function multiplyMatrices(m1, m2) {
  const result = new Array(m1.length)
    .fill(0)
    .map(() => new Array(m2[0].length)
      .fill(0));

  return result
    .map((row, i) => row
      .map((_, j) => m1[i]
        .reduce((sum, e, k) => sum + (e * m2[k][j]), 0)));
}

```