38 - Judah marries a Canaanite, and has two sons. They both die without producing an heir. He wrongly doesn't provide his daughter-in-law with a husband. So she disguises and prostitutes herself to him, and bears two sons. He hypocritically condemns her, and is thus rebuked by his own condemnation.
39 - Joseph is sold to Potiphar, and his service benefits Potiphar greatly; Joseph is promoted. Potiphar's wife pursues and falsely accuses him. Potiphar puts him in his prison, but lets the warden promote him there.
40 - Joseph interprets the butler and baker's dreams rightly, but the butler forgets to mention Joseph to Pharoah.
41 - Pharaoh has a dream, which Joseph interprets; he is promoted to rule at 30 years old, and oversees Egpyt's economy for good, knowing what is coming.