Categories
Mastering Development

Is there a better way of copying elements of an array without knowing the length of the new array?

Say I have an array of 8 elements: old_array = [6, 3, 0, 12, 14, 2, 10, 5] and I start at the last element old_array[7]=5. I want to use the new element as the index of the next element I want to copy from old_array to new_array. Result is new_array = [0,2,5]. Here is […]