Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 87bbdb3

Browse files
committedFeb 8, 2024
feat: solved 4th stage of the Hyperskill project "Hangman"
1 parent c0f1974 commit 87bbdb3

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed
 

‎hyperskill/09_hangman/04/.gitkeep

Whitespace-only changes.

‎hyperskill/09_hangman/04/main.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
const input = require('sync-input');
2+
3+
const title = `H A N G M A N`;
4+
console.log(title);
5+
6+
const words = ["python", "java", "swift", "javascript"];
7+
const word = words[Math.floor(Math.random() * words.length)];
8+
const hint = word.substring(0, 3) + "-".repeat(word.length - 3);
9+
10+
const guess = input(`Guess the word ${hint}: `);
11+
12+
if (guess === word) {
13+
console.log("You survived!");
14+
} else {
15+
console.log("You lost!");
16+
}

0 commit comments

Comments
 (0)
Please sign in to comment.