April 16th, 2019
var bankBalance = $50000;
var autopilot = {
    thingYouWant: 'autopilot'
    cost: $5000;
}
var fsd = {
    thingYouWant: 'fsd'
    cost: $7000;
}

var otherThingsYouReallyWant = [
    {
        thingYouWant: 'vacation',
        cost: $6000
    }
    ,{
        thingYouWant: 'cottage',
        cost: $120000
    }
    ,{
        thingYouWant: 'boat',
        cost: $20000
    }
    ,{
        thingYouWant: 'trailer',
        cost: $22000
    }    
];

function buy(purchase){
    log(purchase);
    bankBalance -= purchase.cost;
}

if(otherThingsYouReallyWant.length > 0){
    foreach(otherThingsYouReallyWant as nextConsideredPurchase){
        if(bankBalance > nextConsideredPurchase.cost){
            buy(nextConsideredPurchase);
        }
    }    
}

if(bankBalance > autopilot.cost){
    buy(autopilot);
}

if(bankBalance > fsd.cost){
    buy(fsd);
}

Posted In:

April 16th, 2019

ABOUT THE AUTHOR:
I am TSLA Long. Model 3 Owner. Brother of a Model 3 owner. Son of a Model S owner and Tesla enthusiast. Buy a Tesla