Unable to compare Serial.readString() to string

Hello

I've been messing a bit with serial communications & I'd like to match the serial.readString to a string for an if statement I now have a code, yet it keeps giving false when I type 'a' (<- without quoting) in the serial bar.
here's my code:

String a = "a";
void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  Serial.setTimeout(200);
}

void loop() {
  // put your main code here, to run repeatedly:
  if (Serial.available() > 0) {

    String command = Serial.readString();
    Serial.print(command);
    if (command.equals(a)) {
      Serial.print("hello"); // <- need this
    }  else {
      Serial.print("crap");
    }

  }
}
    Serial.print(command);

Don't do that.

Do this, instead:

Serial.print("command: [");
Serial.print(command);
Serial.println("]");

What does the output look like?

command: [a]

is not the same as

command: [a
]

the output of that is:

command: [a
]

when copy pasted
but it looks like:

command: [a]

how do I fit the line break in the string a?

I still suspect that you have a non-printing character. Add:

Serial.print("string length:");
Serial.print(a.length());

After printing command. If the length is not 1, you have non-printing characters in the String.

If that is the case, use a.trim() to get rid of them.

trimming fixed it, thanks!