function data(arr){ newdata=arr.slice(arr.length/2) newdata2=arr.slice(0,arr.length/2) return {list1:[...newdata],list2:[...newdata2]} } arr = [1,2,3,4,5] console.log(data(arr))