// the global Array
var s = [23, 65, 98, 5];
Array.prototype.myFilter = function(callback) {
var newArray = [];
// Add your code below this line
this.forEach(function(x) {
if (callback(x) == true) {
newArray.push(x);
}
});
// Add your code above this line
return newArray;
};
So in this code , What does callback
store?
If its the array , then should’nt it be callback[x]
instead of callback(x)
Hi! It’s not an array, the callback
parameter is supposed to be a function than returns a boolean value.
By the way, it would be really helpful if you could link to this challenge so that we can have more context for the code and give you more helpful details, but I hope this answered your initial question 
Link to the challenge
Ok, so callback
is supposed to return boolean , But in context of the solution the problem. I really don’t understand what the callback
is used for .
Can anyone explain what the solution is actually doing?
I think @camperextraordinaire explained it pretty well, so I don’t have much to add to this. If you want another example of a method taking a function as a parameter, it’s the forEach
method that you used in your code (you passed the function as its argument, right?) 
Anyway, in this particular case, as the challenge says, you’re trying to recreate the filter
array method - you take an argument (in this case a function), then iterate through the array that called this method with forEach
and add whichever element returns true
when passed as an argument to the callback
function to the newly created array called newArray
that you’ll eventually return.
Not sure if this was clear enough of an explanation? If you have more specific questions, I’m here to try and help 