Creating a Picture Frame

Published by Mubashir Hassan in

Create a function that takes the width, height and character and returns a picture frame as an array of String.

Examples

getFrame(4, 5, "#") ➞ [
  "####",
  "#  #",
  "#  #",
  "#  #",
  "####"
]
// Frame is 4 characters wide and 5 characters tall.


getFrame(10, 3, "*") ➞ [
  "**********",
  "*        *",
  "**********"
]
// Frame is 10 characters  wide and 3 characters tall.


getFrame(2, 5, "0") ➞ ["invalid"]
// Frame's width is not more than 2.

Notes

  • Remember the gap.
  • Return "invalid" if width or height is 2 or less (can't put anything inside).
Watch a quick demo on how Edabit works.