javascript-tutorial / en.javascript.info

Modern JavaScript Tutorial
https://javascript.info
Other
23.13k stars 3.84k forks source link

Array methods [Tasks] Filter range "in place" typo #3612

Open GaneshS288 opened 8 months ago

GaneshS288 commented 8 months ago

https://javascript.info/array-methods#tasks (The page in question)

[Filter range "in place"]

Write a function filterRangeInPlace(arr, a, b) that gets an array arr and removes from it all values except those that are between a and b. The test is: a ≤ arr[i] ≤ b.

the 'between' in task description implies excluding numbers 1 and 4 so only 2 and 3 should be valid.

let arr = [5, 3, 8, 1];

filterRangeInPlace(arr, 1, 4); // removed the numbers except from 1 to 4

alert( arr ); // [3, 1]

Yet here we have 1 along with 3. The answer is also same as previous task filterRange. Please fix the wording or use an && operator in the solution.