Categories: javascript

Array Filter Method

The Array filter method is used to check against a given condition.

Task: print out all multiples of 3 in the given array:

let x = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15];

Answer:

let x = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15];

mulValue = (val) => {
return val % 3 === 0;
}

let result = x.filter(mulValue);
alert(result) // 3,6,9,12,15

Recent Posts

How to Filter Vulgar Words in React Native

If you're building a social, chat, or comment-based mobile app using React Native, protecting your…

24 hours ago

How to Build Faster Mobile Apps With Native Wind Library

The Cross-Platform ImperativeLet's face it: building separate iOS and Android apps wastes resources. React Native…

2 days ago

The Surprisingly Simple Secret to Getting Things Done

We live in an age of infinite distraction and overwhelming ambition. Grand goals shimmer on…

3 days ago

How to Create Reusable Components in React JS

Reusable components are modular UI building blocks designed for versatility. Instead of writing duplicate code…

3 days ago

Check if Number, Word or Phrase is a Palindrome in JavaScript

What is a Palindrome? A palindrome is any word, phrase, number, or sequence that reads…

1 week ago

How Facial Recognition Software Works

Facial recognition technology is rapidly changing how we interact with devices, access services, and enhance…

2 weeks ago