Reputation: 335
I'm trying to output ascii art via console log but since it includes escape characters I can't compile, how to prevent this?
The ascii art is something like this:
______ _
| ____| | |
| |__ __ ____ _ _ __ ___ _ __ | | ___
| __| \ \/ / _` | '_ ` _ \| '_ \| |/ _ \
| |____ > < (_| | | | | | | |_) | | __/
|______/_/\_\__,_|_| |_| |_| .__/|_|\___|
| |
|_|
console.log(``)
fails and normal quotes will also complain about the escape characters.
Upvotes: 0
Views: 3026
Reputation: 827
Another way would be to use a tool (instead of manually trying) to 'rectify' a string so it is logged as intended by escaping characters that prevent its interpretation as a string.
Execute this snippet to see your desired output:
console.log(" ______ _ \r\n | ____| | | \r\n | |__ __ ____ _ _ __ ___ _ __ | | ___ \r\n | __| \\ \\\/ \/ _` | \'_ ` _ \\| \'_ \\| |\/ _ \\\r\n | |____ > < (_| | | | | | | |_) | | __\/\r\n |______\/_\/\\_\\__,_|_| |_| |_| .__\/|_|\\___|\r\n | | \r\n |_| ")
An example of such a utility can be found here: https://www.freeformatter.com/javascript-escape.html
Additionally, here's an article that covers escape sequences: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String#escape_notation
Upvotes: 4