for (int count =1; count <= NUMBER_OF_TURNS; count++){
string Guess = GetGuess();
(...)
}
Apologies for being a code-nazi, but I can see the Guess string being re-declared inside a ‘for’ loop. That’s something we’ve covered earlier as a wrong thing to do. I would think that you declare a variable once outside a loop and then assign values to it, however many times you like. Something along the lines of:
string Guess = "";
for (int count =1; count <= NUMBER_OF_TURNS; count++){
Guess = GetGuess();
(...)
}
I was actually surprised the console didn’t crash on the second try. Without the loop, the code would look like this:
string Guess = GetGuess();
string Guess = GetGuess();
string Guess = GetGuess();
string Guess = GetGuess();
string Guess = GetGuess();
And we’ve covered that earlier that the code wouldn’t compile.
Question - Why did the compiler allow for it?