The primary function of the adrenal glands is hormone production, which plays a crucial role in the body's response to stress. The adrenal cortex produces corticosteroids, such as cortisol, which help regulate metabolism, blood sugar levels, and immune response. It also secretes aldosterone, which aids in regulating blood pressure by controlling sodium and potassium levels in the body. The adrenal medulla releases catecholamines, such as adrenaline (epinephrine) and norepinephrine, which prepare the body for 'fight or flight' situations by increasing heart rate, dilating air passages, and mobilizing energy stores. Together, these hormones ensure the body can respond effectively to various physical and emotional stresses.