This loop crashes the browser when run, but I can't see why - function getN is one function of three designed to factorise quadratic equations. I am sure it is the loop causing the problem, I have tested this and the browser only crashes when the for loop is present. Any help will be appreciated.
function getN(decP){
var a = document.getElementById("a-f").value;
var b = document.getElementById("b-f").value;
var c = document.getElementById("c-f").value;
var n_1 =0;
var n_2 =0;
var result = Math.pow(10, (decP*-1));
var a_c = a*c;
var neg_a_c = 0;
var pos_a_c = 0;
if(a_c<0){
neg_a_c = a_c;
pos_a_c = a_c*-1
}
else{
pos_a_c = a_c;
neg_a_c = a_c*-1;
}
for(x=neg_a_c;x<=pos_a_c;x+result){
if(x!==0){
if(x+(a_c/x)===b){
var num1 = x;
var num2 = a_c/x;
}
}
}
divideByCoefficient(num1, num2)
};
x+resultonly evaluates the value, you are not storing it anywhere. Guess you want:x+=result