JSFiddle - React, Tailwind, and code Playground
by Jonathan Smith
HTML
<div id="process"></div>
JavaScript
var plugins = [{
name: 'red',
count: 1
}, {
name: 'blue',
count: 3
}];
var lines = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm','n','o','p','q','r','s','t'];
var pluginCounter = 0;
for (var i = 0; i < lines.length; i++) {
for (var j = 0; j < plugins.length; j++) {
if (pluginCounter < plugins[j].count) {
document.getElementById("process").innerHTML += "Line: " + lines[i] + ", plugin used: " + plugins[j].name + "<br />";
pluginCounter++;
break;
} else {
pluginCounter = 0;
break;
}
}
}