How is the parameter (arr) linkied to the variable, var testArray

Thanks Jeremy. II haven’t gave instruction in the code for testArr to be used, only in the log and I’m wondering is that where its being called? However when I change testArr to test in both the variable name and any parts in the log, to return undefined is baffling when its simply the name of the variable.

Can you share the code you are talking about?

You are calling the function inside of the console log. The console log does not change the fact that the function is being called.

function myFunction(argument1, argument2, argument3) {
  // This is a function definition
}

myFunction(arg1, arg2, arg3); // This is a function call
console.log(myFunction(arg1, arg2, arg3)); // This is still a function call

the instruction to use testArr is here:

the first argument of the function should be an array

testArr is an array, it is defined just a few lines above where the function is called

if you write nextInLine(arr, 6), there is not a variable named arr in the code

1 Like

Thank you all very much. I now see that the function is independant of anything, its the rule of the function. The variable is what we set but isn’t link edto the function until we ask for it to run with testArr by requesting an output via console.log(nextInLine(testArr, 6)) o r simply nextInLine(testArr, 6) therefore without printing.

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.