Note that initially it is displaying $x$ instead of $1x$, but when new math expression is generated, it displays $1x$ instead of $x$ or $1(x-3)$ instead $(x-3)$. If the coefficicient is 1 it should not be displayed. We will fix that in the next page.
Here we show step by step methods on how we factor. These steps are generated dynamically by the revised script given below.
<script>
function changeProblem() {
m = Math.floor(10 * Math.random()) + 1;
n = Math.floor(10 * Math.random()) + 1;
s = m + n;
divElement = document.getElementById("equation");
str = "<p/>$x^2" + "-" + (m+n) + "x" + "+" + m*n + "$";
str += "<p/>$=x^2" + "-" + m + "x" + "-" + n + "x" + "+" + m*n + "$";
str += "<p/>$=x(x- " + m + ")-" +n+"(x -" + m + ")$";
str += "<p/>$=(x" + "-" + m + ")(x" + "-" + n + ")$";
divElement.innerHTML = str;
MathJax.Hub.Queue(["Typeset",MathJax.Hub,"equation"]);
}
</script>