Why is this Function not running properly?

/*Create a function called indexFinder that will loop over an array and
return a new array of the indexes of the contents e.g. [243, 123, 4, 12] would return [0,1,2,3].
Create a new variable called ‘indexes’ and set it to contain the indexes of randomNumbers.

( I keep getting an error that indexes is not defined)*/

let randomNumbers = [1, 3453, 34, 456, 32, 3, 2, 0];

function indexFinder(arr) {
  var indexes = [];
  for (i=0; i<arr.length; i++) {
    return indexes;

What code are you using to call the function indexFinder? I do not see a sample call.

If I make a call to your indexFinder function and use randomNumbers as the argument, your function correctly returns an array of indexes.

indexFinder(randomNumbers); //  [ 0, 1, 2, 3, 4, 5, 6, 7 ]

The program I’m working through automatically runs the function when you save it.

If that is the case, why do you even need to create the array called randomNumbers in your code. Is the function called with randomNumbers as the argument or another array?

Without seeing how the function is called, all I can tell you is that your function does return an array of indexes if it is called with an array for the function argument.

The commented out section at the top pf my post is all that is provided in the problem. The declared randomNumbers array is already initialized in the question. I didn’t create it.

I think it may be a glitch in the testing program.

Then I think they want you to reference the global variable randomNumbers inside the function instead of using a parameter (i.e. arr) to pass an array in. Try that instead and see what happens.

Ok, I’ll just do that. Thank you for the help!