javascriptascii

How do you input an ASCII art image into the console in JS?


I'm trying to make this ASCII image shown in the console:

_______                                       
\  ___ `'.            /|                 .--. 
 ' |--.\  \           ||                 |__| 
 | |    \  '          ||                 .--. 
 | |     |  '         ||  __        __   |  | 
 | |     |  | _    _  ||/'__ '.  .:--.'. |  | 
 | |     ' .'| '  / | |:/`  '. '/ |   \ ||  | 
 | |___.' /'.' | .' | ||     | |`" __ | ||  | 
/_______.'/ /  | /  | ||\    / ' .'.''| ||__| 
\_______|/ |   `'.  | |/\'..' / / /   | |_    
           '   .'|  '/'  `'-'`  \ \._,\ '/    
            `-'  `--'            `--'  `" 

However, I'm getting multiple errors since I do not know how you would input this to make it show up in the console when I activate the code.


Solution

  • Use a template literal to embed newlines in the string. You'll need to escape the backticks that are in the string.

    console.log(`_______                                       
    \  ___ \`'.            /|                 .--. 
     ' |--.\  \           ||                 |__| 
     | |    \  '          ||                 .--. 
     | |     |  '         ||  __        __   |  | 
     | |     |  | _    _  ||/'__ '.  .:--.'. |  | 
     | |     ' .'| '  / | |:\`  '. '/ |   \ ||  | 
     | |___.' /'.' | .' | ||     | |\`" __ | ||  | 
    /_______.'/ /  | /  | ||\    / ' .'.''| ||__| 
    \_______|/ |   \`'.  | |/\'..' / / /   | |_    
               '   .'|  '/'  \`'-'\`  \ \._,\ '/    
                \`-'  \`--'            \`--'  \`" `);