Hey, I'm new to this forum and just started Javascript because my maths teacher challenged me to create a program to solve factoring questions. My code stops working at around the 20th line, and I don't know why. I've been using jsfiddle.net as my code compiler if that makes a difference.

This is my code:

I use the alert() thing to let me know when the code has passed a certain point so I can pinpoint where the problem is. Unfortunately, I know where the problem is, I just don't know what it is.Code:var ax2 = prompt('What is the ___x^2?'); var bx = prompt('What is the ___x?'); var c = prompt('What is the ___?'); //get the original question vars /*-----\/BELOW IS NOT MY CODE!!\/-----*/ function gcf(a, b) { if (b === 0) { return a; } else { return gcf(b, a % b); } } /*-----^^ABOVE IS NOT MY CODE!!^^-----*/ //euclid's algorithm (finds gcf) var multiplier = gcf(gcf(ax2, bx), c); //get the gcf for later use (multiplier(num + num)(num + num)) alert(multiplier); ax2 = ax2 / multiplier; bx = bx / multiplier; c = c / mulitplier; //divides question vars by gcf alert('We have divided by multiplier'); var abx3 = ax2 * bx; for (i = 1; i++; i <= Math.sqrt(abx3)) { //start for loop if (abx3 % i === 0) { //if i goes evenly into abx3 if (abx3 % i + i == bx) { //if the two possible factors equal bx var num1 = ax2; var num2 = abx3 % i; var num3 = ax2; var num4 = i; } } } alert('We have finished for loop!'); var num12 = gcf(num1, num2); var num34 = gcf(num3, num4); alert('We have found GCF of the two numbers for each bracket!'); //You really are awesome for reading this far!! num1 = num1 / num12; num2 = num2 / num12; num3 = num3 / num34; num4 = num4 / num34; alert('WE have divided each number by the respective gcf!'); alert(multiplier + "(" + num1 + "x + " + num2 + ")(" + num3 + "x + " + num4);

Thanks for taking the time to read this and, if you decide to help out, thanks for helping out!

-Tim

Sorry if this is in the wrong subforum, I didn't really understand what the different subforums were for, so I picked what I think is the most general one.