Tell us what’s happening:
Why must this be used when just leaving s in works just as well?
**Your code so far**
// The global variable
var s = [23, 65, 98, 5];
Array.prototype.myFilter = function(callback) {
// Only change code below this line
var newArray = [];
for(var i = 0; i < s.length; i++) {
if(callback(s[i]) === true) {
newArray.push(s[i]);
}
}
// Only change code above this line
return newArray;
};
var new_s = s.myFilter(function(item) {
return item % 2 === 1;
});
**Your browser information:**
User Agent is: Mozilla/5.0 (X11; CrOS x86_64 13421.102.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.199 Safari/537.36
.
Challenge: Implement the filter Method on a Prototype
Link to the challenge: