Created
April 21, 2019 22:18
-
-
Save noudadrichem/9a192b851f75ae2e16ae8459cf119cc1 to your computer and use it in GitHub Desktop.
splits an array in 2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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