Any solution I try to this problem gives me:
// running tests
TypeError: Cannot read property ‘message’ of undefined
Even tried both given solutions on the help page and I repeatedly get this error, can anyone help?
Thanks.
**Your code so far**
// The global variable
var s = [23, 65, 98, 5];
Array.prototype.myFilter = function(callback) {
// Only change code below this line
this.forEach( (el) => callback(el) && newArray.push(el) );
// 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 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.150 Safari/537.36.
Challenge: Implement the filter Method on a Prototype
Link to the challenge:
