I am not sure what I\'m doing wrong here, every time I run it, it goes through the if
part even when it\'s not true? So the \'else\' never runs.
#in
The problem is your if
Statement:
if (choice == "F" or "f"){
basically, what you say here is:
If choise is "F" or if "f". You need to understand: True is everything besides zero (0
). "f"
is NOT zero, so it is true. You could also wirte (or
= ||
):
if (coice == "F" || true)
which is the same like:
if (true)
So in order for your code to work, you need:
if (choice == "f" || choice == "F")
That would do what you expect.