how can i call getwallet function and filter list which has balance more than 0 [closed]

Data is in nested object format which i am getting from an api and the data format is { "info": { "makerCommission": "10", "takerCommission": "10", "buyerCommission": "0", "sellerCommission": "0", "canTrade": true, "canWithdraw": true, "canDeposit": true, "updateTime": "1639767562245", "accountType": "SPOT", "balances": [ { "asset": "BTC", "free": 0.00000371, "locked": 0.00000000 }, { "asset": "LTC", "free": 0.00000769, "locked": 0.00000000 } }


Passing a value info.balances in a function but it is giving an error. i can use object('info.balances') directly and access its data but i want to filter the data so i can get only those value which are greater than 0.

    ```html
    <!DOCTYPE html>
    <html lang="en">
      <head>
        <title>Comment</title>
        <meta charset="utf-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1" />
        <!-- <link rel="stylesheet" type="text/css" href="style.css"> -->
            
        <link rel="stylesheet" href="https://pro.fontawesome.com/releases/v5.10.0/css/all.css" integrity="sha384-AYmEC3Yw5cVb3ZcuHtOA93w35dYTsvhLPVnYs9eStHfGJvOvKxVfELGroGkvsg+p" crossorigin="anonymous" />
        <!-- CSS only -->
        <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous" />
        <!-- JavaScript Bundle with Popper -->
        <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" crossorigin="anonymous"></script>
              
              
        <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" />
        <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script>
      </head>
      <body>
    
        <div class="main-body">
          <header>
    
    
    
            <div id="main">
              <table id="table_id" cellspacing="0" width="100%">
                <thead>
                  <tr class="bg-dark">
                    <th class="grey">asset</th>
                    <th class="grey">free</th>
                    <th class="grey">locked</th>
                  </tr>
                </thead>
              </table>
            </div>
          </div>
          <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.11.3/css/jquery.dataTables.css" />
      
          <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
          <script type="text/javascript" charset="utf8" src="https://cdn.datatables.net/1.11.3/js/jquery.dataTables.js"></script>
    
    
          <script>
            function getWalletJSON(data) {
                console.log(46, data);
                let arr = data.filter(function(elem) {
                    console.log((elem.free > 0));
                return (elem.free > 0)
                });
            }
          </script>
        
          <script>
            $(document).ready(function(){
                $('#table_id').DataTable( {
                    ajax: {
                        // url: 'https://jsonplaceholder.typicode.com/comments',
                        url: 'http://design.trailingcrypto.com/api/trade/balances?exchange=binance',
                        dataSrc: getWalletJSON(info.balances)
                    },
                    columns: [
                        // { data: 'asset'},
                        {   data: null,
                            orderable: false,
                            className: 'hvhb',
                            render: function (data, type, row, ){
                                let newdata ='';
                                //     if(data.free >= 1 ){
                                // //    console.log(data.asset);\
                                //  newdata = `${data.asset}`
                                // // return newdata;
                                //     }
                                //     return newdata;
                                if(data.free >0 ) newdata = newdata + `</br>(${data.asset})`;
                                console.log(newdata);
                                return newdata; 
                            }
                        },
                        // { data: 'free'},
                                
                        {   data: null,
                            orderable: false,
                            className: 'hvhb',
                            render: function (data, type, row, ){
                                // if(data.free >= 1 ){
                                //    console.log(data.free);
                                let newdata = `${data.free}`;
                                return newdata;
                            }
                                        
                        },
                                
                        // { data: 'locked'},
                    ]
                });
            })
          </script>
      </body>
    </html>
    ```

You are not returning anything from your getWalletJSON function. The return statement that you do have belongs to the filter function.

function getWalletJSON(data) {
    console.log(46, data);
    let arr = data.filter(function(elem) {
        console.log((elem.free > 0));
        return (elem.free > 0)
    });
    return arr;
}