I want to pass two callbacks and return a result if only the two passed callback as arg are true
Here is the code
let myMap = function(array, cb, callbacks) {
let emptyArr = []
for(let i = 0; i < array.length; i++){
let test = cb(array[i]) && callbacks(array[i])
emptyArr.push(test)
}
return emptyArr
}
The result needed
let triple = function (n) {
return 3 * n;
};
let half = function (n) {
return n / 2;
};
console.log(myMap([7, 3, 2, 9, 8], triple, half));
// [ 21, 1.5, 6, 4.5, 24 ]