There are a number of typos causing you trouble. It looks like some variables were renamed, but you didn't rename all occurrences of them. Also, you're starting the final loop with i = i
instead of i = 0
.
// was: pos = i - 1;
// should be:
j = i - 1;
// was: for (var i = i; i <array. length; i++)
// should be:
for (var i = 0; i <array.length; i++)
// was: output.innerHTML+=numbers[x]+ ' , ';
// should be:
output.innerHTML += array[i] + ' , ';
A working example: http://codepen.io/paulroub/pen/zqsuC