for some reason only the element with the index of 0 is being removed. and also, can i access it more then once using the splice() method?
function myFunction(arr, val) {
for (let i = 0; i < arr.length; i++) {
if (arr[i] === val) {
return arr.splice(i);
}
}
}
console.log(myFunction([2, 3, 4, 3, 2, 1], 3));