solution outside the tutorial

This commit is contained in:
Mau Di Bert 2019-01-24 08:17:14 -03:00 committed by GitHub
parent 8c1782b50c
commit 30d62b78ca
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -0,0 +1,14 @@
``` js run
function filterRange(arr, a, b) {
// added brackets around the expression for better readability
return arr.filter(item => (a <= item && item <= b));
}
let arr = [5, 3, 8, 1];
let filtered = filterRange(arr, 1, 4);
alert( filtered ); // 3,1 (matching values)
alert( arr ); // 5,3,8,1 (not modified)
```