<p>Given a text file of many lines, where fields within a line are delineated by a single <code>$</code> 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.</p>
<p>Use the following text to test your programs:</p>
testString: 'assert(typeof formatText === ''function'', ''<code>formatText</code> is a function.'');'
- text: '<code>formatText</code> with the above input and "right" justification should produce the following: '
testString: 'assert.strictEqual(formatText(testInput, ''right''), rightAligned, ''<code>formatText</code> with the above input and "right" justification should produce the following: '');'
- text: '<code>formatText</code> with the above input and "left" justification should produce the following: '
testString: 'assert.strictEqual(formatText(testInput, ''left''), leftAligned, ''<code>formatText</code> with the above input and "left" justification should produce the following: '');'
- text: '<code>formatText</code> with the above input and "center" justification should produce the following: '
testString: 'assert.strictEqual(formatText(testInput, ''center''), centerAligned, ''<code>formatText</code> with the above input and "center" justification should produce the following: '');'