Based on the implication that Yehuda got married after Yosef was sold, and that it was 22 years later that Yaacov and the family come down to Egypt, during that time Yehuda has his 3 children by the daughter of Shua, marries two of them to Tamar, they both die, keeps Shelah from her so that he can grow up, then has two children by her.
How old were Er and Onan when they died?