Don't forget intelligence. According to the movie, and I believe it is correct in outline, this was crucial. It enabled what amounted to an ambush of the Japanese by the Americans.
I loved the scene in the movie where Charlton Heston was talking to Hal Holbrook, who was explaining their theories about the interecepted radio communications. Heston exclaimed in exasperation, "You're guessing!" Unperturbed, Holbrook replied, "We like to call it analysis."
I think the real edge we had was getting the Yorktown back in action just 48 hours after it was very nearly destroyed. The Japanese were certain it had been as they left if dead in the water burning furiously.
It was very nearly a miracle that those shipyard workers (just another example of the capability of WWII Americans I have mentioned before) could get it back into fighting trim in such a short time.
If not for the Yorktown they would have had 4 against 2.