Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

array.filter

// filter(): returns a new array with all elements that pass the test
// If no elements pass the test, an empty array will be returned.

const words = ['spray', 'limit', 'elite', 'exuberant', 'destruction', 'present'];

const result = words.filter(word => word.length > 6);

console.log(result);
// expected output: Array ["exuberant", "destruction", "present"]
Source by developer.mozilla.org #
 
PREVIOUS NEXT
Tagged:
ADD COMMENT
Topic
Name
3+5 =