Question: need help turning my psuedo code into javascript code so i can make this game called Spaceman which the theme is The player must
need help turning my psuedo code into javascript code so i can make this game called Spaceman which the theme is The player must lose after a certain number of wrong guesses."
wrong guesses and the player loses
the player needs to guess the hidden word by guessing letters while having a limit to the number of guesses
there is a list that has a certain number of words. A random word will be chosen and the player will have to guess the word
Start Game
wordlist space"galaxy", "astronaut","planet"
guessedletters
SET maxwrongguesses
FUNCTION newgame
SET Word Random from wordlist
ADD letterguessed TO guessedletter
SET wrongguesses to
SET displayword to Length of wordtoguess
WHILE wrongguesses maxwrongguessses And displayword Contains
Display display word
Display "Guessed Letters: guessedletters
Display "Wrong guesses left: maxwrongguesses wrongguesses
INPUT guess As character
If guess on guessedletters
Display "YOU already guessed that letter."
Continue WHILE
Add guess to guessedletters
If guess In wordtoguess
For each index, letter IN wordtoguess
FOR each index, Letter IN wordtoguess
IF letter guess
Replace displaywordindex with guess
Else
INCREMENT wrongguesses by
IF displayword DOES NOT CONTAIN
Display "Congratulations! You've guessed the word:" wordtoguess
Else
Display "Game Over! The word was:" wordtoguess
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
