javascript filter

Solutions on MaxInterview for javascript filter by the best coders in the world

showing results for - "javascript filter"
Charlie
04 Jan 2020
1ngOnInit() {
2  this.booksByStoreID = this.books.filter(
3          book => book.store_id === this.store.id);
4}
Lea
09 Jan 2017
1var words = ['spray', 'limit', 'elite', 'exuberant', 'destruction', 'present'];
2
3const result = words.filter(word => word.length > 6);
4
5console.log(result);
Fernando
30 Oct 2017
1const arr = [1, 2, 3, 4, 5, 6];
2const filtered = arr.filter(el => el === 2 || el === 4);	//[2, 4]
Ilyess
06 Apr 2017
1const filtered = array.filter(item => {
2    return item < 20;
3});
4// An example that will loop through an array
5// and create a new array containing only items that
6// are less than 20. If array is [13, 65, 101, 19],
7// the returned array in filtered will be [13, 19]
Luis
22 Feb 2019
1const numbers = [2, 4, 5, 3, 8, 9, 11, 33, 44];
2const filterNumbers = numbers.filter((number) => number > 5);
3console.log(filterNumbers)
4//Expected output:[ 8, 9, 11, 33, 44 ]
Lennard
18 Jun 2016
1const myNum = [2,3,4,5,6,7,8,9,10];
2//using filter gives us a new array
3const divisibleBy3 = myNum.filter(eachNum => eachNum%3==0); 
4console.log(divisibleBy3); //output:[3,6,9]
similar questions
queries leading to this page
javascript filter