I must work with the following slogan: "Let's create three functions and see how to start working with callbacks.
The first function will be called double. It will receive a number and return double.
The second function will be called triple. It will receive a number and return triple.
The third function will be called applyCallback and will receive a number and a function as a parameter. This will return the value of applying said function to the value it received."
I solved it in the following way:
let numero1 = 2
function doble(numero1) {
return (doble * numero1);
};
function triple(numero1){
return (triple * numero1);
};
function aplicarCallBack(numero1, doble) {
return aplicarCallBack;
};
aplicarCallBack(2, doble);
It has me really confused since I just started to see this topic and I don't understand it much, but I would like and it would be very useful for me the help to see what I am doing wrong and correct the error. From already thank you very much!
Hello friend, I hope you are well, look, I took your code and I solved it this way.
I will explain the first function what it takes is a value x from its parameters and within the body of the function it does a calculation which multiplies the number entered by two, the second function is basically the same and finally we have our last function which makes the callback call to another function and basically it receives two parameters which are a number x and a function, it can be any of those created previously, within the body of the function what was done was the creation of a variable the which will contain the result of the function and here we use the function that we pass as a parameter and within it we will place the number that it also receives as a parameter performs its respective function and returns it,Finally, we print by console and use our last function, that's it, we pass two data which are a number x and some of our previous functions and that's all
Finally, I recommend you visit this page here you can find documentation of anything for JavaScript https://developer.mozilla.org/en-US/docs/Glossary/Callback_function
I hope it helps, greetings.