var a=prompt('A', 1); var b=prompt('B', 2); var c=prompt('C', 3); var d=Math.pow(b, 2)-4*a*c; if(d < 0) alert('Discriminant is negatief: '+d); else{ if(d == 0){ var x = -b / 2*a alert('1 oplossing: x='+x); } else{ var x1 = (-b - Math.sqrt( d)) / 2*a; var x2 = (-b + Math.sqrt( d)) / 2*a; alert('2 oplossingen: x1='+x1+'\nx2='+x2) } }
E
val