js特效 求和

求和

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<body>

    <script>
        var arr1=[1,2,3,4,5,6,7,8,9];
        var sum1=0;
        for (var i=0;i<=arr1.length;i++) {
            if (typeof arr1[i]=="number") {
                sum1+=arr1[i];
            }
        }

        document.write(sum1);

    </script>
</body>
</html>
posted @ 2022-12-06 22:21  轻风细雨_林木木  阅读(18)  评论(0编辑  收藏  举报