I came across the following problem in my algebraic geometry class and can't figure out how to solve it.
Let $X \subset \mathbb{A}^n$ be an affine variety. Let $\mathscr{O}_{X}$ denote the sheaf of regular functions on $X$ and $\mathscr{O}_{X, a}$ its stalk at the point $a \in X$.
Prove that the local ring $\mathscr{O}_{X, a}$ is an integral domain if and only if $a$ lies in exactly one irreducible component of $X$.
I have proved that $A(X)_{I(a)} \cong \mathscr{O}_{X, a},$ I have tried looking at the codimension of the point $a$, and have considered Nakayama's lemma for one direction, but I am very stuck and would enjoy any tips or hints. I am also quite new to algebraic geometry and don't know anything about schemes, so if you can refrain from utilizing those, I would appreciate it. Thanks!