Hint: A function $f:A\to B$ is defined by choosing, for each element $x\in A$, an element $f(x)\in B$ for $x$ to go to. There are $n$ elements of $B$ to choose from, for each element of $A$. There are $n$ elements of $A$. The choices are independent (where you choose to send $x\in A$ has no bearing on where you can choose to send a different $y\in A$).
Consider the fact that if you have two choices to make, and choice 1 has $d_1$ options and choice 2 has $d_2$ options, if the choices can be made independently then you have $d_1\times d_2$ options overall.
It may help to work out some simple cases first. Suppose $A$ has just 1 element. How many functions $f:A\to B$ are there, if $B$ has $n$ elements?
$A=\{x\}\qquad\longrightarrow\qquad B=\left\{\matrix{z_1\\ z_2\\ \vdots\\ z_n}\right\}$
What about if $A$ has two elements, say $A=\{x,y\}$? Then a function $f:A\to B$ is uniquely determined by choosing $f(x)\in B$ and $f(y)\in B$, and the choices are independent.