Question: > 
> In class we learned the number of functions from an $m$-element set to an $n$-element set is $n^{m}$. So this answer should be $5^{3}$? 
> 
> 
> 

I just need confirmation if my answer is correct, if not explain to me why it's not.

Answer: 
**hint**

From the total number of functions $3^5$ subtract the number of functions which are NOT onto. Suppose your target set is $\{a,b,c\}$. Then 

1. There are only $3$ functions with range as singletons, for example everything mapping to $a$.
2. Now count the number of functions whose range is **of the form** $\{a,b\}$. This will be $3(2^5-2)=90$ (Think why?).

In general, inclusion-exclusion principle is used for such problems.
Let $S\_j$ be all the functions from $\{1,2,3,4,5\}$ to $\{1,2,3\}$ that miss $j$, for $j\in\{1,2,3\}$
$$
N\_k=\sum\_{|A|=k}\left|\,\bigcap\_{j\in A} S\_j\,\right|
$$
Note that $\bigcap\limits\_{j\in A} S\_j$ is the set of functions from $\{1,2,3,4,5\}$ to $\{1,2,3\}\setminus A$.

There are $\binom{3}{k}$ ways to choose $A$.  

For each choice of $A$, there are $(3-k)^5$ functions in $\bigcap\limits\_{j\in A} S\_j$.

Therefore, $N\_k=\binom{3}{k}(3-k)^5$. Using the [Generalized Principle of Inclusion-Exclusion](https://math.stackexchange.com/a/362516), there are
$$
\sum\_{k=0}^3(-1)^k\binom{k}{0}\binom{3}{k}(3-k)^5=150
$$
functions in none of the $S\_j$.