Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialBenjamin Keller
20,763 PointsHow come in the promptForGuess() method we could have a boolean isHit object that later = mGame.applyGuess(guess)?
How come in the promptForGuess() method we could have a boolean isHit object that later = mGame.applyGuess(guess)? I'm a little confused about what the char guess is doing.
James Reynolds
3,325 PointsJames Reynolds
3,325 PointsThe promptForGuess() function just prompts the user for a guess. The guess is passed to the applyGuess() function. Within that function, the guess (or letter) is checked against the answer using (mAnser.indexOf() >= 0) and returns a boolean (True or False). If indexOf() returns the index of the guessed letter the expression is true. If indexOf() returns -1 the expression is false. isHit is not an object but a boolean. You will alway return a boolean.