I'm currently working on a challenge from codesmith's CSX program. The task at hand is to develop a function that receives two callbacks as parameters and returns the callback function that executes successfully with any given input. However, I am struggling to understand how to access the input data within the functions provided. Apologies if my explanation is unclear.
function eitherCallback(cb1, cb2) {
// YOUR SOLUTION HERE
}
// Please attempt to solve the problem without modifying the code below
function filterArray(array, callback) {
const newArray = [];
for (let i = 0; i < array.length; i += 1) {
if (callback(array[i], i, array)) newArray.push(array[i]);
}
return newArray;
}
const arrOfNums = [10, 35, 105, 9];
const integerSquareRoot = n => Math.sqrt(n) % 1 === 0;
const over100 = n => n > 100;
const intSqRtOrOver100 = eitherCallback(integerSquareRoot, over100);
console.log(filterArray(arrOfNums, intSqRtOrOver100)); // expected output: [105, 9]