javascript - HTML Alert usage issue -
hello having current problem of webpage not loading 2 alert dialog boxes, when comment out second box , line of code webpage works adding second box causes whole page not work.
<!doctype html> <!--jason guerrier 2-7-16--> <html> <head> <title> jason guerrier </title> </head> <body> <script> var userage = 0; var value1 = 0; var value2 = 0; var add = 0; var sub = 0; var mul = 0; var div = 0; var mod = 0; var equ; var notequ; var gretha; var grethanequ; var lestha; var lesthaequ; var equequ; var notequequ; userage = prompt("enter age."); if(userage >= 18) { alert("you old enough vote"); } else { alert("unfortunately not old enough vote"); } value1 = prompt("enter whole number"); value2 = prompt("enter second whole number"); add = parsefloat(value1) + parsefloat(value2); sub = value1 - value2; mul = value1 * value2; div = value1 / value2; mod = value1 % value2; alert("result of value 1 + value 2 = " + add + '\n' + "result of value 1 - value 2 = " + sub + '\n' + "result of value 1 * value 2 = " + mul + '\n' + "result of value 1 / value 2 = " + div + '\n' + "result of value 1 % value 2 = " + mod); equ = value1 == value2; notequ = value1 != value2; gretha = value1 > value2; grethanequ = value1 >= value2; lestha = value1 < value2; lesthaequ = value1 <= value2; equequ = value1 === value2; notequequ = value1 !== value2; alert("result of value 1 == value 2 = " + equ + '\n' + "result of value 1 != value 2 = " + notequ + '\n' + "result of value 1 > value 2 = " + gretha + '\n' + "result of value 1 >= value 2 = " + grethanequ + '\n' + "result of value 1 < value 2 = " + lestha + '\n' "result of value 1 <= value 2 = " + lesthaequ + '\n' + "result of value 1 === value 2 = " + equequ + '\n' + "result of value 1 !== value 2 = " + notequequ); </script> </body> </html>
the error getting is:
uncaught syntaxerror: missing ) after argument list
because missing +
operator:
before:
alert("result of value 1 == value 2 = " + equ + '\n' + "result of value 1 != value 2 = " + notequ + '\n' + "result of value 1 > value 2 = " + gretha + '\n' + "result of value 1 >= value 2 = " + grethanequ + '\n' + "result of value 1 < value 2 = " + lestha + '\n' // missing operator here "result of value 1 <= value 2 = " + lesthaequ + '\n' + "result of value 1 === value 2 = " + equequ + '\n' + "result of value 1 !== value 2 = " + notequequ);
after:
alert("result of value 1 == value 2 = " + equ + '\n' + "result of value 1 != value 2 = " + notequ + '\n' + "result of value 1 > value 2 = " + gretha + '\n' + "result of value 1 >= value 2 = " + grethanequ + '\n' + "result of value 1 < value 2 = " + lestha + '\n' + // fixed! "result of value 1 <= value 2 = " + lesthaequ + '\n' + "result of value 1 === value 2 = " + equequ + '\n' + "result of value 1 !== value 2 = " + notequequ);
Comments
Post a Comment