I can compare text to use in string?

Some days ago i tryed to use a string in my loop to compare numbers.
If number is bigest of 50, the loop continues, if not, go to next loop.

But now i have a new problem.

I have one TD in the table with letters, and i need tell to script for continue or not based in the letters.

If TD have value of A1, A2 or M1, continue with the loop.
If have value of M2, M3 or B1, stop the current loop and go to next.

How i can tell the string to understand “A1” “A2” and “M1” is good and “M2”, “M3” and “B1” is bad?

If someone can help me in whatsapp or skype to help me in my questions, i can pay for this too. Only send me a message here. I pay for support.

It would help if I knew what kind of loop. Here is a while loop:

while(something) {
  value = // get value from TD
  if(value == "M2" || value == "M3" || value == "B1") continue
  // now we have "good" values...


continue means “go back to the top of the loop”