My First Attempt at Lecture 44 IsLowercase()

bool FBullCowGame::IsLowercase(FString Word) const
{
	// treat 0 and 1 letter words as lowercase
	if (Word.length <= 1) { return true; }

	for (auto Letter : Word)	// for all letters of the word
	{
		if (islower(Letter)) { // if letter is lowercase
			return true;	// then return true
		}
		else {	// otherwise
			return false;	// return false
		}
	}

	return true; // for cases in which \0 is entered
}

After continuing the lecture video, I now see how I could have made this much simpler!

Thanks for sharing here, looks good

Privacy & Terms