I have an array with anonymous elements. Elements are added to the array via php, like so:
$playlist = array(); while (databaseloop) { $playlist[] = $a_ti
Using Array.prototype.reduce():
let pairs = playlist.reduce((list, _, index, source) => { if (index % 2 === 0) { list.push(source.slice(index, index + 2)); } return list; }, []);
This gives you a 2-dimensional array pairs to work with.
pairs