Hope this is won't take much time, thank you in advance.
so i want to achieve something like this but i don't know how
let arr = [23, 65, 98, 5];
Array.prototype.myFilter = function(callback) {
let newArray = [];
for(let i = 0; i < this.length; i++){
if(callback(param) === ){ // I want only the filtered items to get pushed to the newArray
newArray.push(callback(this[i]))
}
}
return newArray;
};
var new_arr = arr.myFilter(function(item) {
return item % 2 === 1;
});