-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path10-filter.js
More file actions
17 lines (12 loc) · 798 Bytes
/
Copy path10-filter.js
File metadata and controls
17 lines (12 loc) · 798 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
//Filtering Arrays with filter();
//! filter();
/*
! (method) Array<number>.filter<number>(predicate: (value: number, index: number, array: number[]) => value is number, thisArg?: any): number[] (+1 overload)
Returns the elements of an array that meet the condition specified in a callback function.
@param predicate — A function that accepts up to three arguments. The filter method calls the predicate function one time for each element in the array.
@param thisArg — An object to which the this keyword can refer in the predicate function. If thisArg is omitted, undefined is used as the this value.
*/
//! => functions come in handy
const prices = [10.99, 5.99, 3.99, 3.99, 6.59];
const filteredPrices = prices.filter(price => price > 6); //short n concise
console.log(filteredPrices);