JSFiddle - React, Tailwind, and code Playground

by bittersweetryan

JavaScript

//module pattern
(function(window,document,undefined){
    var total = 0;
    var memorize = [];
    var items = []
    
    window.getItems = getItems;
    
    function getItems(sortedArray){
        if(sortedArray[0] < sortedArray[sortedArray.length -1]){
            //we put the lwest priced item last becuase if we loop through that n times and the total is > desired total we are done and can shut down
            sortedArray.reverse();
        }
    }
    
    function testValues(){
        
    }
    
    
    
}(window,window.document))
    
//"namespace" the data
data = {
    sortedItemArray : [
        {name: 'mixed fruit',cost:2.15},
        {name: 'french fries',cost:2.75},
        {name: 'side salad',cost:3.35},
        {name: 'hot wings',cost:3.35},
        {name: 'mozzarella sticks',cost:4.20},
        {name: 'sampler plate',cost:5.80}
    ]
};

getItems(data.sortedItemArray);