Hard coding numbers for testing array sizes is a poor technique. You should use the array's .length attribute:
x.length for the first dim and x[i].length for the second dim