How to import into function an existing function that I have alreqdy created before ?
How to import into function an array ?
function namarray (arr[])
{}
function namfunc (fun())
{}
How to write it in right syntax ?
How to import into function an existing function that I have alreqdy created before ?
How to import into function an array ?
function namarray (arr[])
{}
function namfunc (fun())
{}
How to write it in right syntax ?
It's the same in both cases, you're passing what you want as an argument to the function. With a function, you're just passing the function name, so don't include the () - you use that later when you want to invoke the function
You can of course choose to save your inputs to variables inside the function
// 1) How to import into function an existing function that I have alreqdy created before ?
// 2) How to import into function an array ?
function testFunction () {
return 'I am the test function';
}
function questionOne (input) {
console.log(input());
}
function questionTwo (input) {
console.log(`I was given the input ${input}, which is an ${typeof input}`);
}
questionOne(testFunction);
questionTwo([1,2,3]);
// In reply to comment
let longArray = [1,2,3,4,5,6,7,8,9,11,22,33,44,55,66,77,88,99,111,222,333];
questionTwo(longArray);