// how to copy all the elements of an array except the last one in javascript const initial = arr => arr.slice(0, -1); console.log(initial([1, 2, 3])); // [1, 2]