← Back to challenges

Vertical Text

JavaScriptHardarraysformatting

Instructions

Create a function that converts a string into a matrix of characters that can be read vertically. Add spaces when characters are missing.

Examples

verticalText("Holy bananas") ➞ [
  ["H", "b"],
  ["o", "a"],
  ["l", "n"],
  ["y", "a"],
  [" ", "n"],
  [" ", "a"],
  [" ", "s"]
]

verticalText("Hello fellas") ➞ [
  ["H", "f"],
  ["e", "e"],
  ["l", "l"],
  ["l", "l"],
  ["o", "a"],
  [" ", "s"]
]

Notes

N/A

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