Callback in implement your own flitern method challenge?

Tell us what’s happening:
Could someone explain to me why does the function got an argument named callback? I went through a few challenges and I just don’t seem to understand it. Is it a keyword, or what?
What does a function(callback) do? How does JS know?
Sorry, I don’t even know how to ask. I’m just hoping someone would understand what I’m trying to ask.
If you could point me to a website where it is explained in first grade level :sweat_smile:, I’d be extremely grateful.

Thank you in advance!!

Your code so far

// The global variable
var s = [23, 65, 98, 5];

Array.prototype.myFilter = function(callback) {
// Only change code below this line
let newArray = [];
  this.forEach(function(x) {
    if (callback(x) == true) {
// 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; Ubuntu; Linux x86_64; rv:83.0) Gecko/20100101 Firefox/83.0.

Challenge: Implement the filter Method on a Prototype

Link to the challenge:

It’s just what the parameter to the function is called. Like you have a function:

function add(a, b) {
  return a + b;

a and b aren’t keywords, they’re just the names of the parameters. Same with the filter function you’re asked to define: callback is just the name of the parameter. That parameter is going to be a function, and because a function used this way is commonly called a “callback”, it makes sense to call the parameter callback (rather than x or djfirofnfj or foobar)

1 Like

Thank you Dan, it’s simple then. I shouldn’t overcomplicate it. Thanks!