Example
function noOfLooping(m,n) {
if(m > n) {
smallestValue = n;
} else {
smallestValue = m;
}
if(smallestValue % 2 == 0) {
return smallestValue/2;
} else {
return (smallestValue+1)/2;
}
}
function squarePrint(m,n) {
var looping = noOfLooping(m,n);
for(var i = 0; i < looping; i++) {
for(var j = i; j < m - 1 - i; j++) {
console.log(i+''+j);
}
for(var k = i; k < n - 1 - i; k++) {
console.log(k+''+j);
}
for(var l = j; l > i; l--) {
console.log(k+''+l);
}
for(var x = k; x > i; x--) {
console.log(x+''+l);
}
}
}
squarePrint(6,4);