Skip to content

Conversation

@copelandhouse2
Copy link
Owner

Code for the following...

  • In class project on Thu
  • Checkpoint 1 - Mastermind

// 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));

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!

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) => {

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants