Making a Box 2.0!

Published by Matt in

This is based on Helen Yu's Making a Box challenge. This challenge is the same execpt that instead of an array of strings, your function should output a matrix of characters.

Examples

charBox(1) ➞ [
  ["#"]
]

charBox(4) ➞ [
  ["#", "#", "#", "#"],
  ["#", " ", " ", "#"],
  ["#", " ", " ", "#"],
  ["#", "#", "#", "#"]
]

charBox(2) ➞ [
  ["#", "#"],
  ["#", "#"]
]

Notes

As an added bonus, try making charBox(0) output [[]] and make any strings, non-integers, and negative numbers output -1.

Watch a quick demo on how Edabit works.