How To Split An Array In Half

[Solved] How To Split An Array In Half | Perl - Code Explorer | yomemimo.com
Question : How to split an Array in half

Answered by : graceful-grasshopper-nr6wt3dgljdo

const splitInHalf = arr => [arr.slice(0, Math.ceil(arr.length / 2)), arr.slice(Math.ceil(arr.length / 2))];

Source : https://dev.to/martinkr/1-line-of-code-how-to-split-an-array-in-half-4hkj | Last Update : Thu, 03 Feb 22

Answers related to how to split an array in half

Code Explorer Popular Question For Perl