I am looking to create a function named createCoffee which will take a function argument called knowHow.
function createCoffee(knowHow){
var x=new knowHow(coffee,beans,milk,sugar);
knowHow.create();
}
This will allow me to use different knowHow functions for creating the coffee.
Next, I will define a sample knowHow function:
var x=function oneWay(a,b,c,d){
console.log(a+b+c+d)
};
Then I will pass x to the createCoffee function.
Subsequently, I will initialize variables a=5, b=1, c=2, d=2 and call createCoffee(x).
The expected outcome is the logging of the sum of the variables. Could it be related to variable scope?
Is my example logically correct? How can I specify the variables in the oneWay(...) function?