When I try to run this code without the Number(), it doesn't work.
ar filter = (arr, fn) => {
let filteredArr = [];
for(const i in arr){
if(fn(arr[i], Number(i))) filteredArr.push(arr[i])
}
return filteredArr;
};
I don't understand why this code doesn't work without the Number(), if the index is some number, at least 0, it's a integer, then it should work... Could you help me? I would be really grateful.
filter? what is the value offn? hint: object property names are always typeString