While attempting to format my console output in hackmud, I found myself spending entirely too long formatting, copy, and pasting ASCII letters directly into a messy echo. I decided to write a script to display ASCII Text dynamically, by supplying an array of ASCII text broken down by row along with an display string.
Initially I attempted to concat strings whole letters at a time and found it too sloppy of a process and ultimately meant a messy output with little flexibility. I settled on taking the ASCII font a row at a time. Utilizing .indexOf() I compared the string letter against a string containing the alphabet and used that value to display the ASCII font. I looped through the display string each row and concated a row together before moving onto the next row. Finally displaying the rows separated by a new line character. I wanted the script to be more flexible allowing for variable width and height letters, so I included 2 parameters defining those dimensions.
I had originally wrote this in a golf friendly way. I have expanded the code slightly for readability, commented it and put it into a JSFiddle for you to explore and test.