String Like Square

Published by 0osh4d0wo0 in

Create a function that takes a number and returns a string like square.

Examples

createSquare(-1) ➞ ""

createSquare(0) ➞ ""

createSquare(1) ➞ "#"

createSquare(2) ➞ "##\n##"

createSquare(3) ➞ "###\n# #\n###"

createSquare(4) ➞ "####\n#  #\n#  #\n####"
"####
#  #
#  #
####"

Notes

Square width <= 16383

Watch a quick demo on how Edabit works.