two buttons for a single out put

I've recently started Arduino and I am trying to get two push button inputs to turn on an LED but the only condition is that both of the push button have to be on for the LED to be on. thankyou for any feedback

int switchState = 0;
int button1 = digitalRead(2);
int button2 = digitalRead(3);
void setup(){
  pinMode(14,OUTPUT);
  pinMode(10,OUTPUT);
  pinMode(2,INPUT);
  pinMode(3,INPUT);
}
void loop(){
  if(button1 == LOW) {
    digitalWrite(14, LOW);
    digitalWrite(10, LOW);
} 
else {
  digitalWrite(10, HIGH);
  digitalWrite(14, HIGH);
}
  if(button2 == LOW) {
    digitalWrite(14, LOW);
    digitalWrite(10, LOW);
  }
  else {
    digitalWrite(10, HIGH);
    digitalWrite(14, HIGH);
 }
}

you need to use AND (&&)

so you get.

if(button1 == HIGH && button2 == HIGH)
turn led on
else
turn led OFF

That would be

  if (button1 && button2)

No need to compare truth values against truth values when what's wanted in an 'if' is a truth value anyway. HIGH is true and LOW is false.

No need to compare truth values against truth values when what's wanted in an 'if' is a truth value anyway. HIGH is true and LOW is false.

It is, on the other hand, actually necessary to call digitalRead() inside loop.

And, I completely disagree with you. Comparing the return code from digitalRead() to HIGH or LOW shows that you know what the function returns for the way you have the switches wired.

MarkT:
No need to compare truth values against truth values when what's wanted in an 'if' is a truth value anyway. HIGH is true and LOW is false.

That happens to be true, but the documentation doesn't specify that this is the case. If you rely on that, then you are relying on undocumented behaviour.

MarkT:
No need to compare truth values against truth values when what's wanted in an 'if' is a truth value anyway. HIGH is true and LOW is false.

I must say that when I am reading my own code I find the lengthier if(button1 == HIGH && button2 == HIGH) much easier to follow. I'm sure the compiler can optimize properly.

...R