Javascript plaatst de getallen achterelkaar in plaats van ze op te tellen;
280+500 wordt 280500 in plaats van 780. Aftrekken lukt echter wel.
Wat heb ik fout gedaan?
<html>
<head>
<title>Optellen</title>
</head>
<body>
<SCRIPT type="text/javascript">
a1=280
b1=500
c1=a1+b1
document.write("<BR>a1 = ",a1)
document.write("<BR>b1 = ",b1)
document.write("<BR>c1 = ",c1)
a2=window.prompt("a2 = ","280")
b2=window.prompt("b2 = ","500")
c2=a2+b2
document.write("<BR>a2 = ",a1)
document.write("<BR>b2 = ",b2)
document.write("<BR>c2 = ",c2)
a3=window.prompt("a3 = ","280")
b3=window.prompt("b3 = ","500")
c3=b3-a3
document.write("<BR>a3 = ",a3)
document.write("<BR>b3 = ",b3)
document.write("<BR>c3 = ",c3)
</script>
</body>
</html>
280+500 wordt 280500 in plaats van 780. Aftrekken lukt echter wel.
Wat heb ik fout gedaan?
<html>
<head>
<title>Optellen</title>
</head>
<body>
<SCRIPT type="text/javascript">
a1=280
b1=500
c1=a1+b1
document.write("<BR>a1 = ",a1)
document.write("<BR>b1 = ",b1)
document.write("<BR>c1 = ",c1)
a2=window.prompt("a2 = ","280")
b2=window.prompt("b2 = ","500")
c2=a2+b2
document.write("<BR>a2 = ",a1)
document.write("<BR>b2 = ",b2)
document.write("<BR>c2 = ",c2)
a3=window.prompt("a3 = ","280")
b3=window.prompt("b3 = ","500")
c3=b3-a3
document.write("<BR>a3 = ",a3)
document.write("<BR>b3 = ",b3)
document.write("<BR>c3 = ",c3)
</script>
</body>
</html>