Install word-game

// Menu: Word Game
// Description: Guess letters to win!
// Author: John Lindquist
// Twitter: @johnlindquist
let playAgain = true
while (playAgain) {
let {
data: [word],
} = await get(
`https://random-word-api.herokuapp.com/word`
)
let correct = false
let guesses = []
while (!correct) {
let [...letters] = await arg(
{ placeholder: "Guess a letter/s:", hint: word }, //remove hint to make it more challenging 😉
word
.split("")
.map(char => (guesses.includes(char) ? char : "*"))
.join("")
)
guesses = guesses.concat(...letters)
correct = word
.split("")
.every(char => guesses.includes(char))
}
playAgain = await arg(`🏆 "${word}"! Play Again?`, [
{ name: "Yes", value: true },
{ name: "No", value: false },
])
}