javascript - Filter objects array -


i got array this:

const xx = [   {     name: "alex",     income: 324300,     total: 3030000   },   {     name: "snake",     income: 3433000,     total: 34323000   } ]; 

i want check if income larger 300000 , if name stored or logged.

this have tried, dont understand how works so..

var f = {}; (var = 0, len = xx.length; < len; i++) {     f[xx[i].id] = xx[i];     if(f[income]>=500000){         console.log(xx[i]);     } } 

you can use array.filter filtering array , array.foreach iterating on console.log or w/e want it.

const xx = [    {      name: "alex",      income: 324300,      total: 3030000    },    {      name: "snake",      income: 3433000,      total: 34323000    },    {      name: "wake",      income: 4,      total: 3    }  ];    xx.filter(function(x) {    return x.income > 30000;  }).foreach(function(x){    console.log(x)  });


Comments

Popular posts from this blog

java - SSE Emitter : Manage timeouts and complete() -

jquery - uncaught exception: DataTables Editor - remote hosting of code not allowed -

java - How to resolve error - package com.squareup.okhttp3 doesn't exist? -