My goal is to make a function that moves the list items from ar1 far enough forward that I can fit ar2 in the space that I've made. (#1) I am taking the indices of ar1 copying them and moving them forward, then I am putting the indices of ar1 where the item I just copied is. (#2) I have tested my loop without my conditions and the loop is valid. The problems seem to be with my conditions (#1), neither of them will stop the loop (#2) independently, so I concluded that there was no reason to make a second loop.
No where in the script have I changed the length of ar2 or interrupted the counter. The condition is never met.
var firstArray = [];
for (var h = 0; h < 10; ++h) {
firstArray[h] = h;
}
secondArray = firstArray;
secondArray.reverse();
function joinArray(ar1, ar2, index) {
/* #2 */
for (var i = 0; i < ar2.length; i++) {
/* #1 */
ar1[index+ar2.length+i] = ar1[index+i];
ar1[index+i] = ar2[i];
}
console.log(ar1);
}
joinArray(firstArray, secondArray, input);