JSFiddle - React, Tailwind, and code Playground
HTML
<div id="contents" />
CoffeeScript
# Calls function fn with consSize items from array a.
eachCons = (a, consSize, fn) ->
for i in [0..(a.length-consSize)]
fn(a[i..i+consSize-1])
# Sample usage
a = [1,2,3,4,5,6]
printer = (s) -> $("#contents").append("<p>#{s}</p>")
eachCons(a, 3, printer)