Skip to content

Instantly share code, notes, and snippets.

@puyo
Created Oct 1, 2015
Embed
What would you like to do?
Animated ASCII artwork on the JS console
<html>
<body>
<script>
var hangmanStages = [
`
`,
`
|
|
|
|
|
|
|
`,
`
|---------
|
|
|
|
|
|
`,
`
|---------
| |
|
|
|
|
|
`,
`
|---------
| |
| O
|
|
|
|
`,
`
|---------
| |
| O
| |
|
|
|
`,
`
|---------
| |
| O
| |-
|
|
|
`,
`
|---------
| |
| O
| -|-
|
|
|
`,
`
|---------
| |
| O
| -|-
| \\
|
|
`,
`
|---------
| |
| O
| -|-
| / \\
|
|
`,
];
var stage = 0;
var delayMs = 500;
var drawHangman = function(){
console.log(hangmanStages[stage]);
stage++;
if (stage < hangmanStages.length) {
setTimeout(drawHangman, delayMs); // again!
}
}
setTimeout(drawHangman, delayMs);
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment