array-interlace

Interlace the contents of an array

Usage no npm install needed!

<script type="module">
  import arrayInterlace from 'https://cdn.skypack.dev/array-interlace';
</script>

README

array-interlace

Interlace the contents of an array

build status

Takes an array, splits it in half, then takes it in turns to push an item from each split array back onto a new array

Installation

npm install array-interlace --save

Usage

var arrayInterlace = require('array-interlace')

console.log(arrayInterlace([ 1, 2, 3, 4, 5, 6 ]))
// Array is [ 1, 4, 2, 5, 3, 6 ]

var interlacedArray = arrayInterlace(array)

Options must include:

  • array - an array to interlace

Credits

Dom Harrington