Get help on this challenge


Please read this explanation before attempting debugging challenges.

What's wrong with my stupid JavaScript code? It's supposed to take an array and reverse it and also double all the even values, so reverseAndAlterArray(array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)) should return array(20,9,16,7,12,5,8,3,4,1), but instead I get array(20,,,,,,8,,,1). I don't get it...

//Doubles even numbers
function times2(input){
  x = input*2;
  if(input%2==0) return x;
  return input;

//Cycles through list and reverses it and doubles even numbers
function reverseAndAlterArray(arr){
  newList = new Array();
  for(x=0; x<arr.length; x++){
    newList[arr.length-x-1] = times2(arr[x]);
  return newList;

list = new Array();
x = 0;
for(x=0; x<10; x++){
  list[x] = x+1;

result = reverseAndAlterArray(list);


Downloadable source code can be found here.

You must be logged in to play. Login or register here

Challenge by ynori7.