Lightning quickly heats the air causing it to expand, which produces the sound of thunder.
Sound travels approximately 1 mile in 5 seconds. Knowing X=r⋅t (where D= distance, r= rate and t= time), how far away is a thunderstrom when you notice a 3-second delay between the flash of lightning and the sound of thunder?