0
Copy and create new array
function filterRange(arr, value1, value2) { var a; var b; var c; var j = 0; var arr1 = []; for (i = 0; i <= arr.length; i++) { if (arr[i] === value1) { a = i; } else if (arr[i] === value2) { b = i; }; }; if (b < a) { c = a; a = b; b = c; }; for (i = 0; a <= i <= b; i++) { arr1[j] = arr[i]; j++; }; return arr1; } var arr = [5, 4, 3, 8, 0]; var filtered = filterRange(arr, 3, 5); console.log(filtered); Help. Where is my mistake? Function not working.
3 Antworten
+ 1
I made some corrections to your code. Hope it helps you.
https://code.sololearn.com/Warr5KdKo19W/?ref=app
0
Of course) Thanks friend.
0
You are welcome 😉