JSFiddle - React, Tailwind, and code Playground

by Serge Zahharenko

HTML

<pre id="log"></pre>

CSS

#log {color:green;}

JavaScript

var jsn = [
	{"i":1, "t":"free"},
	{"i":2, "t":"sales"},
	{"i":3, "t":"free"},
	{"i":4, "t":"free"},
	{"i":5, "t":"free"},
	{"i":6, "t":"sales"},
	{"i":13,"t":"free"},
	{"i":14,"t":"free"},
	{"i":15,"t":"sales"},
	{"i":16,"t":"free"},
	{"i":17,"t":"sales"},
	{"i":21,"t":"free"},
	{"i":22,"t":"free"},
	{"i":23,"t":"sales"},
	{"i":26,"t":"free"},
	{"i":27,"t":"sales"},
	{"i":36,"t":"free"},
	{"i":37,"t":"free"},
	{"i":38,"t":"sales"}
]
for (var i = 0; i < jsn.length; i++) {
    if (jsn[i].t == 'sales') {
        var next = jsn[i+1] || false;
        //var prev = jsn[i-1] || false;
        if (next) {
            if (next.i % 2 == jsn[i].i % 2) { //both are even
                jsn.splice(i, 0, {test:1});
            }
        }
        //console.log(jsn[i])
    }
}
$('#log').html(JSON.stringify(jsn, null, 4));