Baryon number vs electromagnetic charge, what is the difference? What exactly is a Baryon number? I looked up definition from wikipedia and still struggle to understand this. And how does this differ than the
electromagnetic charge?
My textbook did the following computation:

It is calculating the electromagnetic charge right and not the Baryon number?
 A: Baryon number ($B$) and electric charge ($q$) are different quantities.
Both quantities are useful because both obey their own conservation law.
To make this more clear consider the proton ($p$), the neutron ($n$),
their constituent quarks ($u$ and $d$), and the electron ($e$).
Proton and neutron have the same baryon number,
but different electric charges.
$$
\begin{array}{c|c|c}
\text{particle} & B  & q \\ \hline
 p\ (uud) & 1  & +e \\ \hline
 n\ (udd) & 1  & 0 \\ \hline
 u & \frac 13 & +\frac 23 e \\ \hline
 d & \frac 13 & -\frac 13 e \\ \hline
 e & 0 & -e
\end{array}$$
A: A baryon is any particle held together by the strong force (i.e. a type of hadron) that comprises three quarks. An antibaryon has three antiquarks.
The baryon number $B$ is just the sum of all the quarks $n_q$ minus the sum of all the anti-quarks $n_{\bar q}$ :
$$ B = \frac{1}{3}(n_q-n_{\bar q}).$$
So, a quark has baryon number $B = 1/3$, an antiquark $B = -1/3$, baryons have $B = +1$, antibaryons have $B=-1$, mesons have $B=0$ and so on.
A proton, in your example, has $3$ quarks and hence has a $B=1$. Just $1$, a natural number. No units.
Its quarks are $u$, $u$, and $d$, so if we perform the separate and independent from the above sum of the electric charge we get:
$$ q = q_u + q_u + q_d = 2e/3 + 2e/3 -1e/3 = 1e.$$
So the total electromagnetic charge of a proton is $q = 1e = 1.60 \times 10^{-19}$ C.
The baryon number of a proton is $1$.
