← Back to challenges

Making a Box 2.0!

JavaScriptHardvalidationformatting

Instructions

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.

javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.