Skip to content

Instantly share code, notes, and snippets.

@noudadrichem
Created April 21, 2019 22:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save noudadrichem/9a192b851f75ae2e16ae8459cf119cc1 to your computer and use it in GitHub Desktop.
Save noudadrichem/9a192b851f75ae2e16ae8459cf119cc1 to your computer and use it in GitHub Desktop.
splits an array in 2
function getSplittedArray(arr) {
const first = arr.length % 2 === 0
? arr.splice(0, (arr.length/2))
: arr.splice(0, (arr.length/2 + 1))
const second = arr
return [first, second]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment