Skip to content

Latest commit

 

History

History
16 lines (9 loc) · 441 Bytes

filter-method.md

File metadata and controls

16 lines (9 loc) · 441 Bytes

How to Use the Filter Method


In JavaScript, the .filter() method allows you to create a new array by returning the elements of a given array that pass a test implemented by the function you provide.

const years = [2011, 2012, 2013, 2014, 2015]

const even = years.filter((year) => year % 2 === 0)

console.log(even)

link