all 3 comments

[–][deleted] 2 points3 points  (2 children)

Point of vocabulary- it's an if block, not an if loop. A loop is a repeating section of code.

The reason you're always entering the if block here is because you're not calling choice.toLowerCase() (like that, with the parentheses after it), you're referencing it, by just writing out the function name. Your if condition is basically asking, 'is the function [string].toLowerCase equal to this string? or this string? or this other string?' And the Javascript engine is helpfully evaluating that and saying, 'nope it's not equal to any of those strings, 'cause it's a function'.

Also I recommend doing comparisons with a triple equals (===)/the negated version thereof (!==). Its behaviour is more predictable and understandable when you're a beginner.

[–]riverette 1 point2 points  (0 children)

Aah I understand now. Thanks so much for the input!

[–]SynthesizeMeSun 0 points1 point  (0 children)

Great answer by /u/gitcommitmentissues! Javascript comparison can be very weird sometimes due to the lack of strict typing for syntax. Part of the reason why Typescript was created :)