I know that the function $e^{inx}$ can be uniformly approximated on $[-\pi,\pi]$ by polynomials in $x$. I want to use this to show that polynomials are dense in $L^2([-\pi,\pi])$.
Suppose that $f\in L^2([-\pi,\pi])$. I want to show that for any $\epsilon>0$, there is a polynomial $p$ such that $|\int_{-\pi}^\pi (f(x)-p(x))^2dx|<\epsilon$. I was thinking about writing $f$ in terms of its coefficients, i.e. $$f(x)=\sum_{n=-\infty}^\infty \hat{f}(n)e^{inx}$$ But I'm still not sure how this can lead to the polynomial $p$.