Hi, i'm trying to do a hangman game for my home task, and i got a few problems
the first problem is: How can i return a string from for loop?
Here is what i got so far:
for (int i = 0; i < userWord.length(); i++) { if (userGuess.equals(Character.toString(userWord.charAt(i)))) { System.out.print(userGuess.toUpperCase() + " "); } else { System.out.print("_ "); } }
When the userWord is "apple" and userGuess is "a" then it prints " A _ _ _ _ ",
the next time user guess something for example "w" it prints " _ _ _ _ _ "