Merge pull request #755 from maurodibert/patch-22

solution outside the tutorial
This commit is contained in:
Ilya Kantor 2019-01-24 14:20:27 +03:00 committed by GitHub
commit 308179f811
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)
```