-
Notifications
You must be signed in to change notification settings - Fork 0
Mastermind and In Class Project #6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: gh-pages
Are you sure you want to change the base?
Conversation
…rol for user to quite game or restart game.
…trol for user to quit or restart game
| // validEntry() tests the user's entry. Valid entries only contain letters a-h. Only 4 letters. | ||
| function validEntry(myGuess) { | ||
| // Testing for length and testing if all the letters in guess are valid. | ||
| return myGuess.length === solution.length && myGuess.split('').every(myChar => letters.some(validLetter => myChar === validLetter)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice data check here!
| board[board.length] = `${guess} : ${generateHint(guess)}`; | ||
| if (guess === solution) { | ||
| board[board.length] = `${guess} : ${generateHint(guess)}`; | ||
| return true; // player won! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you want to pass the tests your need to return "You guessed it!" on line 128 but I see you did something similar on line 146...
| myGuessArr[i] = ''; // clear out value. This sets us up to look for correct letter test. | ||
|
|
||
| // This piece of code tests for exact match | ||
| myGuessArr.forEach((letter, index) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very clean syntax in a function that can get messy.
Code for the following...