Align columns

FCC link

Given a text file of many lines, where fields within a line are delineated by a single $ character, write a program that aligns each column of fields by ensuring that words in each column are separated by at least one space. Further, allow for each word in a column to be either left justified, right justified, or center justified within its column.

Test

{{test}}

Console output


              
, 'are$delineated$by$a$single$"dollar"$character', 'write$a$program', 'that$aligns$each$column$of$fields

Console output


              
, 'by$ensuring$that$words$in$each

Console output


              
, 'column$are$separated$by$at$least$one$space.', 'Further,$allow$for$each$word$in$a$column$to$be$either$left

Console output


              
, 'justified,$right$justified', 'or$center$justified$within$its$column.' ]; function formatText(input, justification) { }

Console output