zoukankan      html  css  js  c++  java
  • JS,数组小练习

    var arr = [4, 0, 7, 9, 0, 0, 2, 6, 0, 3, 1, 0];
    要求将数组中的0项去掉,将不为0的值存入一个新的数组,生成新的数组

    <!doctype html>

    <html lang="en">

     

    <head>

    <meta charset="UTF-8" />

    <title></title>

    </head>

     

    <body>

     

    </body>

    <script type="text/javascript">

    var arr = [4, 0, 7, 9, 0, 0, 2, 6, 0, 3, 1, 0];

    var pp = [];
    for(var i = 0; i < arr.length; i++) {
    if(arr[i] != 0) {
    pp.push(arr[i]);

    }

    }
    document.write(pp);

    </script>

     

    </html>

  • 相关阅读:
    JSChart_页面图形报表
    hdu 2602(dp)
    hdu 1518(dfs)
    hdu 1716(dfs)
    hdu 1002大数(Java)
    SPOJ 375. Query on a tree (树链剖分)
    poj 1091 跳蚤
    HDU 4048 Zhuge Liang's Stone Sentinel Maze
    HDU Coprime
    HDU Machine scheduling
  • 原文地址:https://www.cnblogs.com/niuniudashijie/p/6080163.html
Copyright © 2011-2022 走看看