I’m working on the credit checker problem. I think that I have a problem with scope most likely, but I’m slightly confused.

I started the project by making a function that would reverse the given array’s items.

function reverseArr(arr) {
  let reverse = [];
  for(i = arr.length - 1; i >= 0; i--) {
  } return reverse;

when I pass a value to the function argument , and log it to the console.


the console returns an array

[ 6, 6, 6, 9, 6, 8, 7, 6, 9, 4, 0, 4, 9, 3, 5, 4 ]

reverse is undefined. That is scope I believe because it is inside the function and not outside of it. What I don’t understand is why when i run :


it returns True, but if I run :


it returns Undefined.

Why is the value of the function call giving the console a value of an array, but it’s still returned as undefined?

I thought I had a pretty good understanding so far, but maybe I need to go back and read some things.

my next step in the process was to make a function that uses this value of the reversed array so I can loop through it and pick out the odd indexes that need to be multiplied by 2.

in case the description above doesn’t help. Here is a screen shot of what I’m getting