var lessSeven = []; var others = []; yourArray.forEach(function(item) { (item.length < 8) ? less7.push(item) : others.push(item); }); yourArray = [lessSeven, others]