When we get to the following section:
Functional Programming: Implement map on a Prototype
people seem to be struggling far more than necessary just by looking at forum posts in regards to the challenge. FreeCodeCamp needs to be more up front stating
You don’t have to use the word “callback” as the name of your argument, Javascript just needs to know that it’s the correct argument name.
because I thought callback
was this whole new thing I had to understand ( almost like a keyword
or it had some code it was invoking behind the scene), when in reality, after much frustration and toil, I find it is just a naming convention some people feel is necessary to highlight what is going on. The truth is if you have a solid understanding of passing arguments to functions and keeping your references right, then the need for the callback
naming convention becomes irrelevant to me. Looking on the internet, this word seems to cause entirely too much confusion!
I saw SO many people on the forums being puzzled by callback
and I have to wonder if their reason is related to mine.
I ended up intentionally writing my solution to the challenge I referenced above as:
var s = [23, 65, 98, 5];
Array.prototype.myMap = function(callFromMultiplyByTwoFunction){
var newArray = [];
for(let i = 0; i < s.length; i++)
{
newArray.push(callFromMultiplyByTwoFunction(this[i]));
}
return newArray;
};
var new_s = s.myMap(function(item){
return item * 2;
});
The fact that you don’t have to use this callback
naming convention is buried in the following post:
http://forum.freecodecamp.org/t/javascript-callback-functions/14658
I think people could learn what they need to more effectively and efficiently if we cleared up the instructions and information presented, just my two cents.