const app = function () { const vals = [100, 2, 3, 4, 5, 6, 7, 8, 10, 15, 20, 40, 50, 75, 1, 200]; const page = {}; const game = {}; vals.sort(function (a, b) { return a - b; }) game.offers = [100, 14, 4, 12, 2, 1].filter(function (x) { return x < vals.length; }) game.offers.sort(function (a, b) { return b - a; }) function init() { console.log(vals); //vals.sort(); console.log(game.offers); } return { init: init } }(); document.addEventListener('DOMContentLoaded', app.init);