That's absolutely correct. The &&
operator (also known as an "AND" operator) means that both parts of the statement need to be true for the whole statement to be true. Otherwise, the whole statement is false.
So as long as neither the player score and the CPU score are equal to 5 (meaning either one of them is either less than or greater than 5), the while loop will continue again and again.
The confusion is completely understandable, especially with the existence of the !
operators (also known as "NOT" operators).
Whenever I get confused with crafting statements like these, I try to break them down into the smallest chunks possible. With this statement, I would start with understanding the first half of the expression (playerScore !== 5
), then move to the second half (cpuScore !== 5
), and finally combine the two.
I hope that helps clear things up!