Welcome to collectivesolver - Programming & Software Q&A. A website you can trust. All programs tested and works. Contact: aviboots(AT)netvision.net.il
BlueHost Web Hosting

Bonsai Boy of New York Bonsai Trees and Accessories

Website Domains Names & Hosting | Domain.com

Ecommerce Software - Best Ecommerce Platform Made for You - Free Trial

DreamHost Web Hosting


Instant Grammar Checker - Correct all grammar errors and enhance your writing

Liquid Web Cloud VPS Hosting

Disclosure We are a professional Programming & Software Q&A website, that receives compensation from some of the links whose we show you with Information. It means that my content may contain affiliate links.

12,757 questions

17,364 answers

573 users

How to filter array in JavaScript ES6

3 Answers

0 votes
const arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; 

const result = arr.filter(n => n > 6); 

console.log(result); 

  
  
       
/*
run:
     
[ 7, 8, 9 ]
   
*/

 




answered Mar 25 by avibootz
0 votes
const arr = ['Node.js', 'JavaScript', 'C++', 'C', 'Python']; 

const result = arr.filter(s => s.length > 5);

console.log(result); 

  
  
       
/*
run:
     
[ 'Node.js', 'JavaScript', 'Python' ]
   
*/

 




answered Mar 25 by avibootz
0 votes
const arr =  [
    {
      id: 1234,
      mission: 'Read a book',
      completed: false
    },
    {
      id: 9872,
      mission: 'Watch a movie',
      completed: false
    },
    {
      id: 7389,
      mission: 'Write the code',
      completed: true
    },
    {
      id: 5621,
      mission: 'Play with kids',
      completed: true
    },
  ]

const result = arr.filter(user => user.id > 3333);

console.log(result); 

  
  
       
/*
run:
     
[
  { id: 9872, mission: 'Watch a movie', completed: false },
  { id: 7389, mission: 'Write the code', completed: true },
  { id: 5621, mission: 'Play with kids', completed: true }
]
   
*/

 




answered Mar 25 by avibootz
...