FOR Loops and if Else Statements

Hello everyone,

I have a sample State App, that displays, capital, population and images once the state is typed correctly… but how can I add a “wrong answer” or “try again” message when the state is typed incorrectly… i know you have to use an If / Else, but it doesn’t seem to cooperate when using a for Loop… any ideas?

@dajanim Is this project for the Create PT?

No this is my own but I need help with the for loop using if else statements

@dajanim You can simplify the conditional by using a complex if statement.
if name == stateName and stateName toLowercase etc
then you can use an else statement to handle the incorrect entry. Check this link below to see more information on JavaScript Operators.
JavaScript Comparison Operators

Please let us know if you have additional questions.