Learn, grow and help others with BBBootstrap
Contribute us with some awesome cool snippets using HTML,CSS,JAVASCRIPT and BOOTSTRAP
Filtering array data in Javascript ES6 with following code
const names = ['Hello', 'John', 'Teena', 'amber', 'meller', 'abuture','anna']; const filterednames = names.filter(name => name.length <= 5) console.log(filterednames); // ['Hello', 'John', 'Teena', 'amber', 'anna']
Numbers can filtered with the following code
const arr = [1, 2, 3, 4, 5, 6, 7, 8, 9]; const filter = arr.filter((number) => number > 5); console.log(filter); // [6, 7, 8, 9]
Try the below code to filter data from array in javascript
var digits = [10, 30, 26, 5, 15,2,4,6,8]; var alldigits = digits.filter(function(digit) { return digit > 7; }); console.log(alldigits); // [10, 30, 26, 15, 8]