Minimize Cash Flow among a given set of friends who have borrowed money from each other using JavaScript.