Steps recursive

by Alex Myronov

JavaScript

const stepsIn = (num, currRow, currCol, line) => {
	if (currRow >= num) {
	  return
  }
  
  if (currCol === num) {
  	console.log(line)
    return stepsIn(num, currRow + 1, 0, '')
  } 
  
	return stepsIn(num, currRow, currCol + 1, currCol <= currRow ? line + '#' : line + ' ')
}

const steps = (num) =>
  stepsIn(num, 0, 0, '')

steps(4)