Answer
$(x+2)(x+1)(x-1)$
Work Step by Step
Grouping the first and second terms and the third and fourth terms, the given expression is equivalent to
\begin{array}{l}\require{cancel}
x^3+2x^2-x-2
\\\\=
(x^3+2x^2)-(x+2)
.\end{array}
Factoring the $GCF$ in each group results to
\begin{array}{l}\require{cancel}
x^2(x+2)-(x+2)
.\end{array}
Factoring the $GCF=
(x+2)
$ of the entire expression above results to
\begin{array}{l}\require{cancel}
(x+2)(x^2-1)
.\end{array}
The expressions $
x^2
$ and $
1
$ are both perfect squares (the square root is exact) and are separated by a minus sign. Hence, $
x^2-1
,$ is a difference of $2$ squares. Using the factoring of the difference of $2$ squares which is given by $a^2-b^2=(a+b)(a-b),$ the expression above is equivalent to
\begin{array}{l}\require{cancel}
(x+2)[(x)^2-(1)^2]
\\\\=
(x+2)[(x+1)(x-1)]
\\\\=
(x+2)(x+1)(x-1)
.\end{array}