var bestPrice = 0;
var bestLocation = "";
for(var p = 0; p < planets.length; p++){
var demand = getBasePriceAndInfluence(itemKey, planets[p], "demand");
var sellPrice = calcPrice(demand[0], demand[1], "demand");
console.log("sell price: " + sellPrice);
console.log("bestprice: " + bestPrice);
if (sellPrice > bestPrice)
{
bestPrice = sellPrice;
bestLocation = p;
console.log("switch for bestprice: " + bestPrice);
}
}
sample log: