Identify the best way of writing a sentence:
Had he realized how close he were to failing, he would not have gone to the party.
1
Had he realized how close he was to failing, he would not have gone to the party.
2
If he had realized how close he was to failing, he would not have gone to the party.
3
Had he had realized how close he was to failing, he would not have gone to the party.
4
When he realized how close he was to failing, he did not go to the party.