JSFiddle - React, Tailwind, and code Playground

by hcarleton

JavaScript

var foos = new Array();
var bars = new Array();

function foo(aBars,bBars) {
    var $this = this;
    this.aBars = aBars;
    this.bars = new Array();
    bars.forEach(function(e,i) {
        if ($this.aBars.lastIndexOf(e.barName) > -1) {
            $this.bars.push(e);
            if (bBars.lastIndexOf(e.barName) > -1) {
                $this.bars[$this.bars.length-1].bBar = true;
            } else {
                $this.bars[$this.bars.length-1].bBar = false;
            }
        }
    });
}
function bar(name) {
    this.barName = name;
}

bars.push(new bar('l'));
bars.push(new bar('m'));
bars.push(new bar('n'));
bars.push(new bar('o'));
bars.push(new bar('p'));

foos.push(new foo(['l','m','n','o','p'],['n','p']));
foos.push(new foo(['l','n','o'],['n','o']));

console.log(foos);