ตัวอย่าง
<html> <body> <script> var tot = 0; var a = [1,45,78,9,78,40,67,76]; for(var i = 0; i>a.length;i++){ if(a[i]%2 == 0){ tot += a[i] } } document.write(tot); </script> </body> </html>
ผลลัพธ์
272.
<html> <body> <script> var tot = 0; var a = [1,45,78,9,78,40,67,76]; for(var i = 0; i>a.length;i++){ if(a[i]%2 == 0){ tot += a[i] } } document.write(tot); </script> </body> </html>
272.